You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marco Mistroni <mm...@waersystems.com> on 2004/01/26 11:41:02 UTC
Logic:iterate and logic:equalquestion
Hi all,
I need to use the logic:equal inside a logic iterate..and I am
Having problems..
My case is that I hae in an ActionForm an HashMap property which
contains
Pairs of String, MyObject. My object has a Boolean property called
status
What I want to do is to loop thru all the objects in my hashmap and, if
the property status has a value of true I want to display button A,
while if it is false I want to display button B.
For testing purposes I am now displaying some text...
I tried with following loop, but seems that is not working properly
// Loop thru all the objects contained in the hashmap
<logic:iterate id="element" name="batchTaskForm" property="tasks">
<tr class="workscreen">
<td align="right" class="workscreen">
// Here I got myObject , and its property 'type'
<bean:write name="element" property="value.type"/>
</td>
<td align="left" class="workscreen">
// Now I should reuse MyObject here....but below code raises
// exception (obviously)
<logic:equal name="element" property="status"
value="true">Active</logic:equal>
<logic:equal name="element" property="status"
value="false">Inactive</logic:equal>
</td>
</tr>
</logic:iterate>
I believe I should go for a bean:define tag but I m not sure how to use
it
Anyone can help?
Thanx in advance and regards
marco
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: problem with nested tags
Posted by Claire Wall <cl...@kurtosys.com>.
You cannot have custom tags within custom tags. As you say you want a
<bean:write> tag within an <html:button> tag, then this will not work as
they are both custom tags. You could get around this by using <bean:define>
and then using the value of this in your html:button tag like so:
<bean:define id="a" name="myForm" value="myValue"/>
<html:button value="<%= (String) a %>"/>
or indeed you could do something like this:
<html:button><bean:write.../></html:button> if you want to use the
<bean:write> for the name of the button.
I'm not certain as to how you are trying to use <bean:write./> in your
<html:button> tag as I dont see an example of it in your code, unless I'm
being completely dopey... :)
cheers
claire w
----- Original Message -----
From: "Marco Mistroni" <mm...@waersystems.com>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Monday, January 26, 2004 12:19 PM
Subject: problem with nested tags
> Hi all,
> I have problem in invoking a javascript for following code...
>
> <nested:iterate id="element" name="batchTaskForm" property="tasks">
> <tr class="workscreen">
> <td align="right" class="workscreen">
> <bean:write name="element" property="value.type"/>
> </td>
> <td align="left" class="workscreen">
>
>
> <nested:equal name="element" property="active"
> value="true">Active since <bean:write name="element"
> property="value.startDate"/>
>
> <html:button property="buttonSelected"
> value="start" title="Start" /> // I should associate this button with a
> javascript method //that accepts as input
> parameter the type property //mentioned
> above
> </html:form>
> </nested:equal>
>
> <nested:equal name="element" property="active"
> value="false">Currently Inactive <html:button property="buttonSelected"
> title="Start" value="start"/></nested:equal>
> </td>
> </tr>
> </nested:iterate>
>
>
> For some reason, the bean:write tag does not work inside an html:button
> ...
>
> Anyone can help?
>
> Thanx in advance and regards
> marco
>
>
> ---------------------------------------------------------------------
> 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
problem with nested tags
Posted by Marco Mistroni <mm...@waersystems.com>.
Hi all,
I have problem in invoking a javascript for following code...
<nested:iterate id="element" name="batchTaskForm" property="tasks">
<tr class="workscreen">
<td align="right" class="workscreen">
<bean:write name="element" property="value.type"/>
</td>
<td align="left" class="workscreen">
<nested:equal name="element" property="active"
value="true">Active since <bean:write name="element"
property="value.startDate"/>
<html:button property="buttonSelected"
value="start" title="Start" /> // I should associate this button with a
javascript method //that accepts as input
parameter the type property //mentioned
above
</html:form>
</nested:equal>
<nested:equal name="element" property="active"
value="false">Currently Inactive <html:button property="buttonSelected"
title="Start" value="start"/></nested:equal>
</td>
</tr>
</nested:iterate>
For some reason, the bean:write tag does not work inside an html:button
...
Anyone can help?
Thanx in advance and regards
marco
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Logic:iterate and logic:equalquestion
Posted by Nicolas De Loof <ni...@cgey.com>.
Solution 1 :
<bean:define id="myObject" name="element" property="value"/>
<logic:equal name="myObject" property="status" value="true">Active</logic:equal>
...
Solution 2 :
<logic:equal name="element" property="value.status" value="true">Active</logic:equal>
...
Nico.
> Hi all,
> I need to use the logic:equal inside a logic iterate..and I am
> Having problems..
> My case is that I hae in an ActionForm an HashMap property which
> contains
> Pairs of String, MyObject. My object has a Boolean property called
> status
>
> What I want to do is to loop thru all the objects in my hashmap and, if
> the property status has a value of true I want to display button A,
> while if it is false I want to display button B.
>
> For testing purposes I am now displaying some text...
>
>
> I tried with following loop, but seems that is not working properly
>
> // Loop thru all the objects contained in the hashmap
> <logic:iterate id="element" name="batchTaskForm" property="tasks">
> <tr class="workscreen">
> <td align="right" class="workscreen">
>
> // Here I got myObject , and its property 'type'
>
> <bean:write name="element" property="value.type"/>
> </td>
> <td align="left" class="workscreen">
>
> // Now I should reuse MyObject here....but below code raises
> // exception (obviously)
>
> <logic:equal name="element" property="status"
> value="true">Active</logic:equal>
> <logic:equal name="element" property="status"
> value="false">Inactive</logic:equal>
>
> </td>
> </tr>
> </logic:iterate>
>
> I believe I should go for a bean:define tag but I m not sure how to use
> it
>
> Anyone can help?
>
> Thanx in advance and regards
> marco
>
>
>
>
> ---------------------------------------------------------------------
> 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