You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by James Turner <tu...@blackbear.com> on 2002/08/09 03:01:05 UTC

Changing value of a defined bean using tags?

Is there an obvious way to do this I'm missing?

Because of the limitations of JSP 1.1, you can't do:

<bean:define name="foundMyLife" value="false" scope="request"/>
<logic:iterate id="aLife" name="lives" type="java.lang.String">
    <logic:equals name="aLife" value="mine">
        <bean:define name="foundMyLife" value="true" scope="request"/>
    </logic:equals>
</logic:iterate>

<logic:equals name="foundMyLife" value="true" scope="request">
I Found My Life!
</logic:equals>

Right now, I'm having to do:

<bean:define name="foundMyLife" value="false" scope="request"/>
<logic:iterate id="aLife" name="lives" type="java.lang.String">
    <logic:equals name="aLife" value="mine">
        <% request.setAttribute("foundMyLife", "true"); %>
    </logic:equals>
</logic:iterate>

<logic:equals name="foundMyLife" value="true" scope="request">
I Found My Life!
</logic:equals>

Is there any way to avoid breaking out into a Scriptlet?

James



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Changing value of a defined bean using tags?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 8 Aug 2002, James Turner wrote:

> Date: Thu, 08 Aug 2002 21:01:05 -0400
> From: James Turner <tu...@blackbear.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: struts-user@jakarta.apache.org
> Subject: Changing value of a defined bean using tags?
>
> Is there an obvious way to do this I'm missing?
>
> Because of the limitations of JSP 1.1, you can't do:
>
> <bean:define name="foundMyLife" value="false" scope="request"/>
> <logic:iterate id="aLife" name="lives" type="java.lang.String">
>     <logic:equals name="aLife" value="mine">
>         <bean:define name="foundMyLife" value="true" scope="request"/>
>     </logic:equals>
> </logic:iterate>
>
> <logic:equals name="foundMyLife" value="true" scope="request">
> I Found My Life!
> </logic:equals>
>
> Right now, I'm having to do:
>
> <bean:define name="foundMyLife" value="false" scope="request"/>
> <logic:iterate id="aLife" name="lives" type="java.lang.String">
>     <logic:equals name="aLife" value="mine">
>         <% request.setAttribute("foundMyLife", "true"); %>
>     </logic:equals>
> </logic:iterate>
>
> <logic:equals name="foundMyLife" value="true" scope="request">
> I Found My Life!
> </logic:equals>
>
> Is there any way to avoid breaking out into a Scriptlet?
>

In JSP 1.1, as you say, you're basically stuck.  This is the kind of thing
that the JSTL tags like <c:set> make much more convenient (but requires
1.2, of course).

> James
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>