You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Frank Maritato <fr...@overture.com> on 2003/12/27 20:29:06 UTC

dynamic arg0 in bean:message?

Hi,

What I want to do is something like this:

<bean:message key="error.minCharacters"
  arg0="<bean:write name="globals" property="minChars" />" />

or

<bean:message key="error.minCharacters"
  arg0="<%=minChars%>" />

Where arg0 is the result of a bean property, but I can't seem to get it 
to work. If I hard-code the value

<bean:message key="error.minCharacters" arg0="20" />

It works, but it kinda defeats the purpose.

What am I doing wrong, or is there a better way to accomplish this?

Thanks
--
Frank


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


Re: dynamic arg0 in bean:message?

Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "Frank" == Frank Maritato <fr...@overture.com> writes:

    Frank> Hi,
    Frank> What I want to do is something like this:

    Frank> <bean:message key="error.minCharacters"
    Frank>   arg0="<bean:write name="globals" property="minChars" />" />

    Frank> or

    Frank> <bean:message key="error.minCharacters"
    Frank>   arg0="<%=minChars%>" />

    Frank> Where arg0 is the result of a bean property, but I can't seem to get it to
    Frank> work. If I hard-code the value

    Frank> <bean:message key="error.minCharacters" arg0="20" />

    Frank> It works, but it kinda defeats the purpose.

    Frank> What am I doing wrong, or is there a better way to accomplish this?

Well, the best way is probably to use the Struts-EL tag library, which will
allow you to do this:

 <bean:message key="error.minCharacters" arg0="${globals.minChars}" />

Your first attempt failed because you can't nest custom tags in custom tag
attributes.

Your second attempt failed (probably) because your scriptlet variable
"minChars" was not declared, or set to the value of your bean property.

-- 
===================================================================
David M. Karr          ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net   ; SCJP; SCWCD; SCBCD





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


Re: dynamic arg0 in bean:message?

Posted by Frank Maritato <fr...@overture.com>.
Thanks everyone! Since I had a jsp:useBean in the page already, I was able to do 
the following:

<%=\"\"+globals.getMinChars()%>


Nicolas De Loof wrote:
> Your first example is invalid :
> 
> <bean:message key="error.minCharacters"
>    arg0="<bean:write name="globals" property="minChars" />" />
> 
> A JSP tag cannot be used as attribute value of another tag (XML syntax)
> 
> This should work :
> 
> <bean:define id="minChars" name="globals" property="minChars" type="String"/>
> <bean:message key="error.minCharacters"  arg0="<%=minChars%>" />
> 
> Nico.
> 
> 
> ----- Original Message ----- 
> From: "Domingo A. Rodriguez S." <do...@yahoo.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Monday, December 29, 2003 1:48 PM
> Subject: Re: dynamic arg0 in bean:message?
> 
> 
> 
>>Either escape the double quotes ("<bean:write name=\"globals\"
>>property=\"minChars\" />" ) or use single quotes ("<bean:write
>>name='globals' property='minChars' />" ).
>>
>> --- Frank Maritato <fr...@overture.com> escribió: > Hi,
>>
>>>What I want to do is something like this:
>>>
>>><bean:message key="error.minCharacters"
>>>  arg0="<bean:write name="globals" property="minChars" />" />
>>>
>>>or
>>>
>>><bean:message key="error.minCharacters"
>>>  arg0="<%=minChars%>" />
>>>
>>>Where arg0 is the result of a bean property, but I can't seem to get it
>>>to work. If I hard-code the value
>>>
>>><bean:message key="error.minCharacters" arg0="20" />
>>>
>>>It works, but it kinda defeats the purpose.
>>>
>>>What am I doing wrong, or is there a better way to accomplish this?
>>>
>>>Thanks
>>>--
>>>Frank
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>
>>_________________________________________________________
>>Do You Yahoo!?
>>Información de Estados Unidos y América Latina, en Yahoo! Noticias.
>>Visítanos en http://noticias.espanol.yahoo.com
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 

-- 
Frank Maritato

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


Re: dynamic arg0 in bean:message?

Posted by Nicolas De Loof <ni...@cgey.com>.
Your first example is invalid :

<bean:message key="error.minCharacters"
   arg0="<bean:write name="globals" property="minChars" />" />

A JSP tag cannot be used as attribute value of another tag (XML syntax)

This should work :

<bean:define id="minChars" name="globals" property="minChars" type="String"/>
<bean:message key="error.minCharacters"  arg0="<%=minChars%>" />

Nico.


----- Original Message ----- 
From: "Domingo A. Rodriguez S." <do...@yahoo.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, December 29, 2003 1:48 PM
Subject: Re: dynamic arg0 in bean:message?


>
> Either escape the double quotes ("<bean:write name=\"globals\"
> property=\"minChars\" />" ) or use single quotes ("<bean:write
> name='globals' property='minChars' />" ).
>
>  --- Frank Maritato <fr...@overture.com> escribió: > Hi,
> >
> > What I want to do is something like this:
> >
> > <bean:message key="error.minCharacters"
> >   arg0="<bean:write name="globals" property="minChars" />" />
> >
> > or
> >
> > <bean:message key="error.minCharacters"
> >   arg0="<%=minChars%>" />
> >
> > Where arg0 is the result of a bean property, but I can't seem to get it
> > to work. If I hard-code the value
> >
> > <bean:message key="error.minCharacters" arg0="20" />
> >
> > It works, but it kinda defeats the purpose.
> >
> > What am I doing wrong, or is there a better way to accomplish this?
> >
> > Thanks
> > --
> > Frank
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
> _________________________________________________________
> Do You Yahoo!?
> Información de Estados Unidos y América Latina, en Yahoo! Noticias.
> Visítanos en http://noticias.espanol.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Re: dynamic arg0 in bean:message?

Posted by "Domingo A. Rodriguez S." <do...@yahoo.com>.
Either escape the double quotes ("<bean:write name=\"globals\"
property=\"minChars\" />" ) or use single quotes ("<bean:write
name='globals' property='minChars' />" ). 

 --- Frank Maritato <fr...@overture.com> escribió: > Hi,
> 
> What I want to do is something like this:
> 
> <bean:message key="error.minCharacters"
>   arg0="<bean:write name="globals" property="minChars" />" />
> 
> or
> 
> <bean:message key="error.minCharacters"
>   arg0="<%=minChars%>" />
> 
> Where arg0 is the result of a bean property, but I can't seem to get it 
> to work. If I hard-code the value
> 
> <bean:message key="error.minCharacters" arg0="20" />
> 
> It works, but it kinda defeats the purpose.
> 
> What am I doing wrong, or is there a better way to accomplish this?
> 
> Thanks
> --
> Frank
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>  

_________________________________________________________
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com

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