How to get the data from a custom propertie that is in a group on an custom control on an Xpage?
-
26-10-2019 - |
题
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?
解决方案
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.
其他提示
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>
If you want to loop, you can just use: for(marker in compositeDate.Marker){ marker.title; }