掲示板
How to get value - text of item in velocity
11年前 に Mk Sin によって更新されました。
How to get value - text of item in velocity
Junior Member 投稿: 74 参加年月日: 12/05/25 最新の投稿
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
11年前 に Mk Sin によって更新されました。
RE: How to get value - text of item in velocity
Junior Member 投稿: 74 参加年月日: 12/05/25 最新の投稿
Last answer, It CAN NOT ?!
11年前 に Scott Palmer によって更新されました。
RE: How to get value - text of item in velocity
Junior Member 投稿: 36 参加年月日: 10/01/08 最新の投稿
Anyone found a way to do this? Having the same issue. Looking into it further.
11年前 に Scott Palmer によって更新されました。
RE: How to get value - text of item in velocity
Junior Member 投稿: 36 参加年月日: 10/01/08 最新の投稿
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
11年前 に Scott Palmer によって更新されました。
RE: How to get value - text of item in velocity
Junior Member 投稿: 36 参加年月日: 10/01/08 最新の投稿
Have added a ticket here: http://issues.liferay.com/browse/LPS-32957 please add your comments/votes/etc.