You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by st...@spamgourmet.com on 2011/10/13 21:15:38 UTC

freemarker radio tag with map literals [solved, kind of]

I'm having a hard time using the freemarker syntax radio tag.  This works fine:
<@s.radio name="cars" list=[ "ford", "toyota" ] />

But using a literal map does not:
<@s.radio name="cars" list={ "ford" : "mustang",  "toyota":"prius" } />

The web page renders:
"freemarker.ext.beans.HashAdapter$1$1$1@7e29d49f" as both the value and label.   I experimented with various listValue parameters to no avail.

Other things I've tried that also don't work:

* Creating a map using OGNL syntax:  list="#{  ... }" -- FM chokes on the # -- "expecting number" error
* using <@s.set name="carList" value="%{ #{ ... } }" />

If this is ever figured out it'd be great to note it in the examples section of this document:
http://struts.apache.org/2.2.3.1/docs/radio.html  (probably also the doc for select)

As well as mentioning freemarker map literal particulars on this document:
http://struts.apache.org/2.2.3/docs/freemarker-tags.html


UPDATE -- After a few hours and checking of source code, I came up with this solution:

<#assign cars = {'ford':'Fusion', 'toyota':'Prius'} />
<@s.radio name="cars" list=cars listKey="key" listValue="%{ getText( value ) }" />

I would have expected it to work without the listKey and listValue attributes.
If you have additional insight I'd love to hear it.

Thanks,

-rgm

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org