Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 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 15:03 Go to next message
Justin Albright is currently offline Justin AlbrightFriend
Messages: 10
Registered: September 2015
Junior Member
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 16:54 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
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 14:52 Go to previous message
Justin Albright is currently offline Justin AlbrightFriend
Messages: 10
Registered: September 2015
Junior Member
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: Thu Nov 15 15:17:39 GMT 2018

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

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

Back to the top