You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Aristides P. Preto Jr" <Ar...@INOV.pt> on 2007/11/22 00:35:45 UTC

Select tag on freemarker

Hello,

In JSP, I could do the following:

<s:set name="entityTypeList" 
value="%{#{'CST':'Customer','SPL':'Supplier','OTH':'Other'}}"/>
<s:select  name="entity.entityType" value="%{entity.entityType}"  
list="entityType"  emptyOption="true" />

How can I  do the same using FreeMarker ?

I get errors if I try this:

<@s.set name="entityTypeList" 
value="%{#{'CST':'Customer','SPL':'Supplier','OTH':'Other'}}" />
<@s.select name="entity.entityType"  value="%{entity.entityType}" 
list="entityTypeList" emptyOption="true"/>

or this:
<@s.set name="entityTypeList" 
value="#{'CST':'Customer','SPL':'Supplier','OTH':'Other'}" />

and the list is not populated if I try this:

<#assign entityTypeList = {"CST":"Customer", "SPL":"Supplier" } >


Note: If I change entityTypeList for a OGNL List (not a hashmap), all 
works file.


I am using struts 2.0.9 and freemarker 2.3.8 on tomcat 5.5.20.

Thanks in advance for any help.
Bests,

-- 
---
Aristides P. Preto Jr. - Aristides.Preto@INOV.pt 
Project Manager - Information Systems  Unit
INOV - Inesc Inovação - http://www.inov.pt - +351-213100444



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


Re: Select tag on freemarker

Posted by "Aristides P. Preto Jr" <Ar...@INOV.pt>.
Hello,

For anyone interested...
After several searches (and some sleeping too :-)), I've finally found a 
possible solution - to use the freemarker "r" (raw) prefix:

<@s.set name="entityTypeList" value=r'#{"CST":"Customer", 
"SPL":"Supplier" }' />
<@s.select name="entity.entityType"  value="%{entity.entityType}" 
list="entityTypeList" emptyOption="true"/>

Found this post to the mailing list: 
http://www.nabble.com/Can-anyone-explain-the-leading-%22r%22-in-OGNL-list-syntax--tf4349553.html#a12395847 
, and also some info on 
http://www.jroller.com/cdaniluk/entry/webwork_and_freemarker_part_deux .

Unfortunatelly, the docs. on 
http://struts.apache.org/2.0.11/docs/freemarker-tags.html does not refer 
this...

Bests,

---
Aristides P. Preto Jr. - Aristides.Preto@INOV.pt
Project Manager - Information Systems  Unit
INOV - Inesc Inovação - http://www.inov.pt - +351-213100444



Aristides P. Preto Jr wrote:
>
> Hello,
>
> In JSP, I could do the following:
>
> <s:set name="entityTypeList" 
> value="%{#{'CST':'Customer','SPL':'Supplier','OTH':'Other'}}"/>
> <s:select  name="entity.entityType" value="%{entity.entityType}"  
> list="entityType"  emptyOption="true" />
>
> How can I  do the same using FreeMarker ?
>
> I get errors if I try this:
>
> <@s.set name="entityTypeList" 
> value="%{#{'CST':'Customer','SPL':'Supplier','OTH':'Other'}}" />
> <@s.select name="entity.entityType"  value="%{entity.entityType}" 
> list="entityTypeList" emptyOption="true"/>
>
> or this:
> <@s.set name="entityTypeList" 
> value="#{'CST':'Customer','SPL':'Supplier','OTH':'Other'}" />
>
> and the list is not populated if I try this:
>
> <#assign entityTypeList = {"CST":"Customer", "SPL":"Supplier" } >
>
>
> Note: If I change entityTypeList for a OGNL List (not a hashmap), all 
> works file.
>
>
> I am using struts 2.0.9 and freemarker 2.3.8 on tomcat 5.5.20.
>
> Thanks in advance for any help.
> Bests,
>


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