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/09/19 18:45:25 UTC

Example for optgroup doesn't work

Regarding:
http://struts.apache.org/2.2.3/struts2-core/apidocs/org/apache/struts2/components/OptGroup.html
and
http://struts.apache.org/2.2.3.1/docs/optgroup.html

The example given at the bottom, when translated in to Freemarker tag syntax, doesn't work.  Here's my FM version:

 <@s.select label="My Selection" name="mySelection" 
   value="POPEYE"
   list={'SUPERMAN':'Superman', 'SPIDERMAN':'spiderman'} >
<@s.optgroup label="Adult"
    list={'SOUTH_PARK':'South Park'} />
<@s.optgroup label="Japanese"
    list={'POKEMON':'pokemon','DIGIMON':'digimon','SAILORMOON':'Sailormoon'} /> 
</...@s.select>

This causes the following exception:

freemarker.core.InvalidReferenceException: Expression optGroupInternalListUiBean.parameters.list is undefined on line 36, column 8 in mx/themes/securelink/optgroup.ftl.
	at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:100)
	at freemarker.core.Environment.visit(Environment.java:210)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:210)
...

If I try and simplify it and use the OGNL syntax I get a different error:
 <@s.select label="My Selection" name="mySelection" value="%{'POPEYE'}"
   list="%{#{'SUPERMAN':'Superman', 'SPIDERMAN':'spiderman'}}" >
</...@s.select>

...
Caused by: freemarker.core.ParseException: Error on line 29, column 22 in */tests/select-list.ftl
Found string literal: 'SUPERMAN'
Expecting: number in */tests/select-list.ftl
	at freemarker.core.FMParser.notStringLiteral(FMParser.java:84)
	at freemarker.core.FMParser.numberLiteralOnly(FMParser.java:147)

Can anyone provide guidance here for using FM literals with select lists?

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