1

I'm working on a custom control that has custom properties.

If I want to use the value of a property it is very easy. For the value of the property "maptype" I can use compositeData.maptype But how do I do this wit groups?

For example I have a goup called "Marker" and there can be multiple of them. Each marker has five properties: "address", "title", "layer", "infotext" and "icon". How do I access for example the value of title on the third marker?

Martin Meijer
  • 21
  • 1
  • 4

3 Answers3

0

If you want to loop, you can just use: for(marker in compositeDate.Marker){ marker.title; }

BvG013
  • 53
  • 7
0

There are many ways to use it. It is just a collection with properties that you can iterate. One way could be to use it inside a repeat control. This is an example how you could use it:

            <xp:repeat id="repeat1" rows="30"
                value="#{javascript:compositeData.Marker}"
                var="rowMarker">

                <xp:label id="lbladdress"
                    value="#javascript:rowMarker.address}">
                </xp:label>
                <xp:label id="lbltitle"
                    value="#javascript:rowMarker.title}">
                </xp:label>

            </xp:repeat>
Ferry Kranenburg
  • 2,625
  • 1
  • 17
  • 23
  • Thank you Ferry, your example is about how you can loop in a repeater, but I want to loop in Javascript. I'm looking for something like compositeData.Marker[2].title but that doesn't work. – Martin Meijer Feb 17 '12 at 09:21
0

the group of properties is interpreted as com.ibm.xsp.binding.PropertyMap java class. The multiple instances are interpreted as java.lang.ArrayList class. Knowing this I would try

compositeData.Marker[2].address

for simple data binding. Or

compositeData.Marker.get(2).get('address')

for accessing via pure javascript.

Denny
  • 161
  • 2
  • Thank you Denny, I solved the problem with your help end some aditional "'". This worked for me: var test = [ #{javascript:"'" + compositeData.marker[0].address + "'"} ]; alert(test); – Martin Meijer Feb 17 '12 at 11:08