Foren
How to get value - text of item in velocity
Mk Sin, geändert vor 11 Jahren.
How to get value - text of item in velocity
Junior Member Beiträge: 74 Beitrittsdatum: 25.05.12 Neueste Beiträge
I have structure with 1 Selection List and 1 Multi-Selection List
In my velocity i use
for Selection List
and
for Mutil-Selection List
But it only return me the type, I want to get both the type(value) and text(name), please show me the way
<dynamic-element name="mySLMenu" type="list" index-type="keyword" repeatable="false">
<dynamic-element name="itemOne" type="0" index-type="" repeatable="false"></dynamic-element>
<dynamic-element name="itemTwo" type="1" index-type="" repeatable="false"></dynamic-element>
</dynamic-element>
<dynamic-element name="myMSMenu" type="multi-list" index-type="" repeatable="false">
<dynamic-element name="itemOne" type="0" index-type="" repeatable="false"></dynamic-element>
<dynamic-element name="itemTwo" type="1" index-type="" repeatable="false"></dynamic-element>
</dynamic-element>
In my velocity i use
$mySLMenu.getData()
for Selection List
and
#if($myMSMenu.getOptions().size() >0)
<select multiple>
#foreach($item in $myMSMenu.getOptions())
<option> $item </option>
#end
</select>
#end
for Mutil-Selection List
But it only return me the type, I want to get both the type(value) and text(name), please show me the way
Mk Sin, geändert vor 11 Jahren.
RE: How to get value - text of item in velocity
Junior Member Beiträge: 74 Beitrittsdatum: 25.05.12 Neueste Beiträge
Last answer, It CAN NOT ?!
Scott Palmer, geändert vor 11 Jahren.
RE: How to get value - text of item in velocity
Junior Member Beiträge: 36 Beitrittsdatum: 08.01.10 Neueste Beiträge
Anyone found a way to do this? Having the same issue. Looking into it further.
Scott Palmer, geändert vor 11 Jahren.
RE: How to get value - text of item in velocity
Junior Member Beiträge: 36 Beitrittsdatum: 08.01.10 Neueste Beiträge
Solution by Chun Ho:
The Liferay structure does not carry the name on the options. Workaround is to define a map in Velocity to show the actual name. Which means you have to duplicate the data somewhat - but at least you only have to do it once in the template and then all your pages using the template will inherit the change. Hopefully Liferay can fix this in an upcoming release so the multi-selection field can be fully utilised.
The Liferay structure does not carry the name on the options. Workaround is to define a map in Velocity to show the actual name. Which means you have to duplicate the data somewhat - but at least you only have to do it once in the template and then all your pages using the template will inherit the change. Hopefully Liferay can fix this in an upcoming release so the multi-selection field can be fully utilised.
#set ($myMSMenuMap = {"item1" : "Item One Full Name" , "item2" : "Item TwoFull Name"})
<h2>List of Stuff: </h2>
#if($myMSMenu.getOptions().size() >0)
<ul>
#foreach($item in $myMSMenu.getOptions())
<li> $myMSMenuMap.get($item) </li>
#end
</ul>
#end
Scott Palmer, geändert vor 11 Jahren.
RE: How to get value - text of item in velocity
Junior Member Beiträge: 36 Beitrittsdatum: 08.01.10 Neueste Beiträge
Have added a ticket here: http://issues.liferay.com/browse/LPS-32957 please add your comments/votes/etc.