You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by be...@accenture.com on 2003/06/27 13:21:51 UTC

bean:define to assign a different value to an existing variable

Apologies for the x-post, I put this in the dev newsgroup by a mistake.

Ben


> In this code excerpt I am defining a bean with bean:define. However, I
> want to conditionally change the value.
>
> According to the struts doc, bean:define either creates, or replaces a
> previous instance of the bean as defined by the id. However, I can't
> see how this is possible, as the bean:define actually writes inline
> java i.e <bean:define name="blah" id="blah/> --> Object blah = "";
>
>
> <logic:iterate name="page_of_results" indexId="index" id="thread">
>
> <bean:define scope="page" name="hot_topic" value="false"
> id="hot_topic"/>
>
>
> <logic:greaterThan name="thread" property="replyCount" value="100">
>     <bean:define scope="page" name="hot_topic" value="true"
> id="hot_topic"/>
> </logic:greaterThan>
>
> .
>
> ..
>
> ....
> <logic:equal name="hot_topic" value="true">
> <img src="/midletsite/images/hot_topic.gif"/>
> </logic:equal>
> </logic:iterate>
>
>
> I've tried replacing the other bean:defines with scriptlets eg,
>
> <logic:greaterThan name="thread" property="replyCount" value="100">
>   <%hot_topic="false"%>
> </logic:greaterThan>
>
> but the bean:write later on seems to have ignored the scriptlet (
> possibly due to the compilation order of the JSP vs. tags?
>
> Can anyone provide a workaround?
>
> Thanks
>
> Ben





Re: bean:define to assign a different value to an existing variable

Posted by Sandeep Takhar <sa...@yahoo.com>.
I don't think you can have it twice on the same page.

You will have to try another way.

sandeep
--- ben.jessel@accenture.com wrote:
> Apologies for the x-post, I put this in the dev
> newsgroup by a mistake.
> 
> Ben
> 
> 
> > In this code excerpt I am defining a bean with
> bean:define. However, I
> > want to conditionally change the value.
> >
> > According to the struts doc, bean:define either
> creates, or replaces a
> > previous instance of the bean as defined by the
> id. However, I can't
> > see how this is possible, as the bean:define
> actually writes inline
> > java i.e <bean:define name="blah" id="blah/> -->
> Object blah = "";
> >
> >
> > <logic:iterate name="page_of_results"
> indexId="index" id="thread">
> >
> > <bean:define scope="page" name="hot_topic"
> value="false"
> > id="hot_topic"/>
> >
> >
> > <logic:greaterThan name="thread"
> property="replyCount" value="100">
> >     <bean:define scope="page" name="hot_topic"
> value="true"
> > id="hot_topic"/>
> > </logic:greaterThan>
> >
> > .
> >
> > ..
> >
> > ....
> > <logic:equal name="hot_topic" value="true">
> > <img src="/midletsite/images/hot_topic.gif"/>
> > </logic:equal>
> > </logic:iterate>
> >
> >
> > I've tried replacing the other bean:defines with
> scriptlets eg,
> >
> > <logic:greaterThan name="thread"
> property="replyCount" value="100">
> >   <%hot_topic="false"%>
> > </logic:greaterThan>
> >
> > but the bean:write later on seems to have ignored
> the scriptlet (
> > possibly due to the compilation order of the JSP
> vs. tags?
> >
> > Can anyone provide a workaround?
> >
> > Thanks
> >
> > Ben
> 
> 
> 
> 
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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