You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Néstor Boscán <ne...@tcs.com.ve> on 2009/01/26 15:52:54 UTC
S2 Using with parameters
Hi
Im using the Struts 2 validation framework and using message properties
like this:
message.requiredfield = The field "${getText(fieldName)}" is required
Now I need to do some extra javascript validations where I need to get the
message from the property files but I cant get:
<s:text name="message.requiredfield"><s:param name="fieldName"
value="projectDocument"/></s:text>
to work. I dont know if this is possible. Do I have to create another
message key for this?
Regards,
Néstor Boscán
RE: Re: S2 Using with parameters
Posted by Néstor Boscán <ne...@tcs.com.ve>.
Yes I also think that only positional parameters would work, which means I
have to create another message just for this case. Struts 2 should allow
developers to use messages with positional parameters with the validation
framework so you can have just one type of message.
-----Mensaje original-----
De: Dave Newton [mailto:newton.dave@yahoo.com]
Enviado el: Monday, January 26, 2009 11:10 AM
Para: Struts Users Mailing List
Asunto: [!! SPAM] Re: S2 Using <s:text/> with parameters
Néstor Boscán wrote:
> message.requiredfield = The field "${getText(fieldName)}" is required
>
> Now I need to do some extra javascript validations where I need to get the
> message from the property files but I cant get:
>
> <s:text name="message.requiredfield"><s:param name="fieldName"
> value="projectDocument"/></s:text>
I don't think that's how it would work; if I had to guess I'd say that
only positional message parameters would be possible--could be wrong
about that.
That said, you can still call the getText() variant that takes a list or
an array--this should be doable using OGNL syntax; something like:
<s:property value="getText('message.requiredField',
{ 'projectDocument' })"/>
IIRC you can also construct actual arrays:
<s:property value="getText('message.requiredField',
new String[] { 'projectDocument' })"/>
if the first way doesn't work.
Dave
---------------------------------------------------------------------
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: S2 Using with parameters
Posted by Dave Newton <ne...@yahoo.com>.
Néstor Boscán wrote:
> message.requiredfield = The field "${getText(fieldName)}" is required
>
> Now I need to do some extra javascript validations where I need to get the
> message from the property files but I can’t get:
>
> <s:text name="message.requiredfield"><s:param name="fieldName"
> value="projectDocument"/></s:text>
I don't think that's how it would work; if I had to guess I'd say that
only positional message parameters would be possible--could be wrong
about that.
That said, you can still call the getText() variant that takes a list or
an array--this should be doable using OGNL syntax; something like:
<s:property value="getText('message.requiredField',
{ 'projectDocument' })"/>
IIRC you can also construct actual arrays:
<s:property value="getText('message.requiredField',
new String[] { 'projectDocument' })"/>
if the first way doesn't work.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org