Fórum

How to get value - text of item in velocity

Mk Sin, modificado 11 Anos atrás.

How to get value - text of item in velocity

Junior Member Postagens: 74 Data de Entrada: 25/05/12 Postagens Recentes
I have structure with 1 Selection List and 1 Multi-Selection List

<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() &gt;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 emoticon
Mk Sin, modificado 11 Anos atrás.

RE: How to get value - text of item in velocity

Junior Member Postagens: 74 Data de Entrada: 25/05/12 Postagens Recentes
Last answer, It CAN NOT ?!
thumbnail
Scott Palmer, modificado 11 Anos atrás.

RE: How to get value - text of item in velocity

Junior Member Postagens: 36 Data de Entrada: 08/01/10 Postagens Recentes
Anyone found a way to do this? Having the same issue. Looking into it further.
thumbnail
Scott Palmer, modificado 11 Anos atrás.

RE: How to get value - text of item in velocity

Junior Member Postagens: 36 Data de Entrada: 08/01/10 Postagens Recentes
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.


#set ($myMSMenuMap = {"item1" : "Item One Full Name" , "item2" : "Item TwoFull Name"})
<h2>List of Stuff: </h2>
    #if($myMSMenu.getOptions().size() &gt;0)
    <ul>
    #foreach($item in $myMSMenu.getOptions())
        <li> $myMSMenuMap.get($item) </li>   
    #end
    </ul>
 #end
thumbnail
Scott Palmer, modificado 11 Anos atrás.

RE: How to get value - text of item in velocity

Junior Member Postagens: 36 Data de Entrada: 08/01/10 Postagens Recentes
Have added a ticket here: http://issues.liferay.com/browse/LPS-32957 please add your comments/votes/etc.