You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "To, Wilson" <Wi...@umusic.com> on 2002/01/03 15:34:22 UTC
problem using the tag
Hi Struters,
I have a problem using the <logic:equal> tag.
I have a bean collection (Array List of value/label pairs of String's - used
in an <html:select>) and I'm using the <logic:iterate> tag to iterate over
the collection. Whilst looping over the collection, I want to test to see
if the value of the collection matches the value of another bean (not a
collection but just a single String value). If so, it will display the
contents of that collection.
I have coded the jsp as follows:
<logic:iterate id="projectCollection" name="projectsList">
<logic:equal name="projectCollection" property="value" value='<bean:write
name="projectCode"/>'>
<bean:write name="projectCollection" property="label"/><br />
</logic:equal>
</logic:iterate>
However, this DOES NOT APPEAR TO WORK. If I replace value='<bean:write
name="projectCode"/>' with value="PH" (i.e. a hardcoded value) then it
works.
Needless to say, if I display the contents of the bean using <bean:write
name="projectCode"/> on it's own, it displays "PH" as expected (without
quotes).
It also seems odd that I tried playing around with declaring variables
within JSP and using that within the <logic:equal> tag as follows but it
also does not give the desired effect:
<% String pcode="PH"; %>
<logic:iterate id="projectCollection" name="projectsList">
<logic:equal name="projectCollection" property="value" value="<% =pcode
%>">
<bean:write name="projectCollection" property="label"/><br />
</logic:equal>
</logic:iterate>
I'm using version 1.0 of Struts and version 3.2.1 of Tomcat.
Can anyone throw any light on this?
Wilson
Re: problem using the tag
Posted by Ted Husted <hu...@apache.org>.
You may want to say
<logic:equal name="projectCollection" property="value"
name="projectCode"/>
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Building Java web applications with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/
"To, Wilson" wrote:
>
> Hi Struters,
>
> I have a problem using the <logic:equal> tag.
>
> I have a bean collection (Array List of value/label pairs of String's - used
> in an <html:select>) and I'm using the <logic:iterate> tag to iterate over
> the collection. Whilst looping over the collection, I want to test to see
> if the value of the collection matches the value of another bean (not a
> collection but just a single String value). If so, it will display the
> contents of that collection.
>
> I have coded the jsp as follows:
>
> <logic:iterate id="projectCollection" name="projectsList">
> <logic:equal name="projectCollection" property="value" value='<bean:write
> name="projectCode"/>'>
> <bean:write name="projectCollection" property="label"/><br />
> </logic:equal>
> </logic:iterate>
>
> However, this DOES NOT APPEAR TO WORK. If I replace value='<bean:write
> name="projectCode"/>' with value="PH" (i.e. a hardcoded value) then it
> works.
>
> Needless to say, if I display the contents of the bean using <bean:write
> name="projectCode"/> on it's own, it displays "PH" as expected (without
> quotes).
>
> It also seems odd that I tried playing around with declaring variables
> within JSP and using that within the <logic:equal> tag as follows but it
> also does not give the desired effect:
>
> <% String pcode="PH"; %>
> <logic:iterate id="projectCollection" name="projectsList">
> <logic:equal name="projectCollection" property="value" value="<% =pcode
> %>">
> <bean:write name="projectCollection" property="label"/><br />
> </logic:equal>
> </logic:iterate>
>
> I'm using version 1.0 of Struts and version 3.2.1 of Tomcat.
>
> Can anyone throw any light on this?
>
> Wilson
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>