You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ignacio de Córdoba <ic...@skios.es> on 2009/04/24 18:55:05 UTC

How to define a String array in FreeMarker

Hi there,
i am using FreeMarker to generate HTML content for mails in my application
(not for the web presentation; I use JSP for that).
I so use FreeMarker directly, not integrated to struts.

My problem is localizing messages with parameters. I am invoking the
freemaker template passing the action (it self) as an object. Then I get the
text invoking struts2 ActionSupport getText method:

This works ok when there are no parameters ( ${action.getText("hello")} )

but suppose portalid is a string variable and I try:

${action.getText("pleaseConfirmYouWantToChangeYourPassword",portalid)}

The problem is that portalid variable should be an array of strings, not a
string. I am new to freemarker and don't know if it is possible to define a
string array inside the template. Something equivalent to java:

String[] portalidArray = new String[]{portalid};

Is it possible? How?

Thanks for any help,
Ignacio
-- 
View this message in context: http://www.nabble.com/How-to-define-a-String-array-in-FreeMarker-tp23220643p23220643.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to define a String array in FreeMarker

Posted by Dave Newton <ne...@yahoo.com>.
Ignacio de Córdoba wrote:
> i am using FreeMarker to generate HTML content for mails in my application
> (not for the web presentation; I use JSP for that).
> I so use FreeMarker directly, not integrated to struts.
> 
> My problem is localizing messages with parameters. I am invoking the
> freemaker template passing the action (it self) as an object. Then I get the
> text invoking struts2 ActionSupport getText method:
> 
> This works ok when there are no parameters ( ${action.getText("hello")} )
> 
> but suppose portalid is a string variable and I try:
> 
> ${action.getText("pleaseConfirmYouWantToChangeYourPassword",portalid)}
> 
> The problem is that portalid variable should be an array of strings, not a
> string. I am new to freemarker and don't know if it is possible to define a
> string array inside the template. Something equivalent to java:

Have you tried just using array notation? I know FreeMarker supports the 
notion of a sequence, but I don't know if it's passable to a Java method 
or not. (I'd guess no, but could definitely be wrong.)

You could always just define this in the action, too, either the array 
or the results of the getText() itself.

> String[] portalidArray = new String[]{portalid};
> 
> Is it possible? How?

Maybe you should ask on a FreeMarker mailing list.

Dave


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