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

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

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 James Mitchell <jm...@apache.org>.
Oh, I also noticed that you are asking user questions on the dev list.
Move this thread over to the users list please.

On Friday 27 June 2003 05:37, ben.jessel@accenture.com wrote:
> 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

-- 
James Mitchell
Software Developer/Struts Evangelist
http://www.struts-atlanta.org
770-822-3359
AIM:jmitchtx



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


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

Posted by James Mitchell <jm...@apache.org>.
On Friday 27 June 2003 05:37, ben.jessel@accenture.com wrote:
> 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" value="false"
> id="hot_topic" name="hot_topic" />
      ^^^^^^^^^        ^^^^^^^^^
For starters, don't do this.  Use different names

>
>
> <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


-- 
James Mitchell
Software Developer/Struts Evangelist
http://www.struts-atlanta.org
770-822-3359
AIM:jmitchtx



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