You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Womack <wo...@adobe.com> on 2005/08/06 02:34:26 UTC
Using Message Resources with Tiles?
I can't imagine that this question has not been asked before, but I could
not dig up answers in the mail archives or the online documentation. I
apologize in advance if there is an obvious answer that I do not see.
Instead of embedding a text value in my tiles definition file like this:
<definition name="default-layout" path="/pages/default-layout.jsp">
<put name="window-title" value="The title of the window here"/>
...
</definition>
I want it to reference the text from the message resources I have already
defined in my MessageResources.properties file:
main.window.title=The title of the window here
Maybe with something like this:
<definition name="default-layout" path="/pages/default-layout.jsp">
<put name="window-title" value="main.window.title"/>
...
</definition>
Is there a way to do this? I'd rather have all of my localizable text in
one place, namely the message properties file. There should be a way to
reference strings from the message properties files by key...right?
I was expecting to find an attribute on the tiles:getAsString jsp tag.
Something like:
<tiles:getAsString name="window-title" useAsMessageKey="true"/>
or
<tiles:getAsString messageKey="window-title"/>
Like I said, I have to believe that this has come up as a question before.
I hope there is a good answer.
Thanks,
-Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Multiple Input Bean
Posted by Tony Smith <qu...@yahoo.com>.
Hi,
Suppose I have a UserBean:
class UserBean{
String name,
String address,
...
public String getName()
...
}
In one jsp page, I want to input multiple people beans
and send back to server. The jsp UI is something like:
People 1:
Name [ ] address [ ]
People 2:
Name [ ] address [ ]
People 3:
Name [ ] address [ ]
[Submit Button]
How do I design my ActionForm and Action?
Thanks,
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Using Message Resources with Tiles?
Posted by Mark Womack <wo...@adobe.com>.
JSTL makes this possible. I am surprised this feature was not built into
tiles at some point without requiring JSTL.
Thank you for the reply and answer. Much appreciated.
-Mark
> -----Original Message-----
> From: Jason Lea [mailto:jason@kumachan.net.nz]
> Sent: Friday, August 05, 2005 6:34 PM
> To: Struts Users Mailing List
> Subject: Re: Using Message Resources with Tiles?
>
> I put keys into the tile definition eg
>
> <definition name="default-layout" path="/pages/default-layout.jsp">
> <put name="windowTitle" value="main.window.title"/>
>
> Then I just treat them as keys. Using either JSTL/EL (<fmt:message>)or
> Struts tags (<bean:message>) to fetch the text from the message resources.
> The tiles tags don't provide a method of getting the value directly from
> the resource.
>
> so I use <tiles:importAttribute scope="request"/> so that the values are
> available in any of my tiles, then using JSTL/EL I can use ${windowTitle}
> in any tag as the key.
>
> eg
>
> <fmt:message key="${windowTitle}"><fmt:param
> value="${someOtherParam}"/> </fmt:message>
>
> or
>
> <bean:message key="${windowTitle}" arg0="${someOtherParam}"/>
>
>
> Mark Womack wrote:
>
> >I can't imagine that this question has not been asked before, but I could
> >not dig up answers in the mail archives or the online documentation. I
> >apologize in advance if there is an obvious answer that I do not see.
> >
> >Instead of embedding a text value in my tiles definition file like this:
> >
> ><definition name="default-layout" path="/pages/default-layout.jsp">
> > <put name="window-title" value="The title of the window here"/>
> >...
> ></definition>
> >
> >I want it to reference the text from the message resources I have already
> >defined in my MessageResources.properties file:
> >
> >main.window.title=The title of the window here
> >
> >Maybe with something like this:
> >
> ><definition name="default-layout" path="/pages/default-layout.jsp">
> > <put name="window-title" value="main.window.title"/>
> >...
> ></definition>
> >
> >Is there a way to do this? I'd rather have all of my localizable text in
> >one place, namely the message properties file. There should be a way to
> >reference strings from the message properties files by key...right?
> >
> >I was expecting to find an attribute on the tiles:getAsString jsp tag.
> >Something like:
> >
> ><tiles:getAsString name="window-title" useAsMessageKey="true"/>
> >
> >or
> >
> ><tiles:getAsString messageKey="window-title"/>
> >
> >Like I said, I have to believe that this has come up as a question
> before.
> >I hope there is a good answer.
> >
> >Thanks,
> >-Mark
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
> >
>
> --
> Jason Lea
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Using Message Resources with Tiles?
Posted by Jason Lea <ja...@kumachan.net.nz>.
I put keys into the tile definition eg
<definition name="default-layout" path="/pages/default-layout.jsp">
<put name="windowTitle" value="main.window.title"/>
Then I just treat them as keys. Using either JSTL/EL (<fmt:message>)or
Struts tags (<bean:message>) to fetch the text from the message resources.
The tiles tags don't provide a method of getting the value directly from
the resource.
so I use <tiles:importAttribute scope="request"/> so that the values are
available in any of my tiles, then using JSTL/EL I can use ${windowTitle}
in any tag as the key.
eg
<fmt:message key="${windowTitle}"><fmt:param
value="${someOtherParam}"/> </fmt:message>
or
<bean:message key="${windowTitle}" arg0="${someOtherParam}"/>
Mark Womack wrote:
>I can't imagine that this question has not been asked before, but I could
>not dig up answers in the mail archives or the online documentation. I
>apologize in advance if there is an obvious answer that I do not see.
>
>Instead of embedding a text value in my tiles definition file like this:
>
><definition name="default-layout" path="/pages/default-layout.jsp">
> <put name="window-title" value="The title of the window here"/>
>...
></definition>
>
>I want it to reference the text from the message resources I have already
>defined in my MessageResources.properties file:
>
>main.window.title=The title of the window here
>
>Maybe with something like this:
>
><definition name="default-layout" path="/pages/default-layout.jsp">
> <put name="window-title" value="main.window.title"/>
>...
></definition>
>
>Is there a way to do this? I'd rather have all of my localizable text in
>one place, namely the message properties file. There should be a way to
>reference strings from the message properties files by key...right?
>
>I was expecting to find an attribute on the tiles:getAsString jsp tag.
>Something like:
>
><tiles:getAsString name="window-title" useAsMessageKey="true"/>
>
>or
>
><tiles:getAsString messageKey="window-title"/>
>
>Like I said, I have to believe that this has come up as a question before.
>I hope there is a good answer.
>
>Thanks,
>-Mark
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
--
Jason Lea
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org