Skip to main content



      Home
Home » Archived » Sapphire » Using ListProperty for attribute of an element(Creating a list of strings as an attribute of an xml element)
Using ListProperty for attribute of an element [message #1708447] Wed, 16 September 2015 11:03 Go to next message
Eclipse UserFriend
I am attempting to use a ListProperty to create a list of strings as an attribute of an xml element. The goal is to be able to create an xml that resembles the following

<Property Name="some string" ... Enums="one, two, three"/>


When I attempt to use the ListProperty it is expecting an element type for Property and I have been able to successfully create this...

<Property Name="thisisaprop">
            <Enum>one</Enum>
            <Enum>two</Enum>
            <Enum>three</Enum>
</Property>


but I somehow need to get the enums as a single string as an attribute of Property.

To get to what I have now my code is...

// *** Enums ***
@Type( base = PropertyEnum.class )
@XmlListBinding( mappings = @XmlListBinding.Mapping( element = "Enum", type = PropertyEnum.class ) )
@Label(standard = "Enums")
	
ListProperty PROP_ENUMS = new ListProperty( TYPE, "Enums" );

ElementList<PropertyEnum> getEnums();


If it is not possible to do it this way, is it possible to somehow use the ListProperty widget that gets generated to create a single string. I really would just like to use the widget because it is easier for the user, but need to adhere to the framework's xml schema for the Enums attribute.

Any help is much appreciated, thank you.
Re: Using ListProperty for attribute of an element [message #1708585 is a reply to message #1708447] Thu, 17 September 2015 12:54 Go to previous messageGo to next message
Eclipse UserFriend
Sapphire includes abstract classes that facilitate implementation of this usecase. Take a look at XmlDelimitedListBindingImpl. There is an example of it's usage in the Contacts Sample. Look for ConnectionsListBinding. In that example, the delimited list string is persisted inside an element, but you can easily persist inside an attribute by feeding it an XmlPath instance that references an attribute.
Re: Using ListProperty for attribute of an element [message #1709279 is a reply to message #1708585] Fri, 25 September 2015 10:52 Go to previous message
Eclipse UserFriend
That worked beautifully! Thank you very much Konstantin!
Previous Topic:New Sapphire plugin repository URLs
Next Topic:Creating custom connection bindings
Goto Forum:
  


Current Time: Mon Jul 21 06:10:08 EDT 2025

Powered by FUDForum. Page generated in 0.11043 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top