| Author |
logic:equal
|
Daniel Silva
Greenhorn
Joined: Nov 10, 2003
Posts: 9
|
|
How can I make to use dinamic values with equal tag, for example: <bean efine id="string" value="<%=1%>" /> <logic:equal name="string" value="1"> The string contained the word Struts </logic:equal> in this case, don't print "The string contained the word Struts" at my scren, but if I change the <bean efine id="string" value="<%=1%>" /> for <bean efine id="string" value="1" /> it's work ok (print the message), What I need to do for make this work fine, I need the dinamic values for compare, maybe I don't need the <bean efine id="string" value="<%=1%>" />, just compare the logic:equal value with other number, but I don't know what attribute should use for it, parameter="<%=dinamicValue%>" or ??? Cheers Daniel S.
|
 |
Benson Fung
Ranch Hand
Joined: Apr 10, 2003
Posts: 201
|
|
string is just the java bean object name. In this java bean, there are couples of attributes/properties. Therefore, logic:equal is to check the property in this java bean is equal to a value you specified. e.g. <logic:equals name="person" property="age" value="30"> I am 30 years old. </logic:equals> it will expect there is getter method in this java bean object, person, called getAge(). This is all I know. Hope it can help you. Benson
|
 |
Wayne Kidd
Greenhorn
Joined: Aug 17, 2003
Posts: 7
|
|
To dynamically take different paths in your jsp with logic:equal you need a bean that gets its value from somewhere else in the application. So, for example, if there is a bean in some scope that has been set in an action: String yesno = null; if (a == "Bob") yesno = "yes"; else yesno = "no"; request.getSession().setAttribute("RESULT", yesno); then tags like these might make sense: <logic:equal name="RESULT" value="yes" > <td>Written by Bob</td> </logic:equal> <logic:equal name="RESULT" value="no" > <td>Not written by Bob</td> </logic:equal>
|
 |
Daniel Silva
Greenhorn
Joined: Nov 10, 2003
Posts: 9
|
|
ok, but my problem is: I'm use the equal inside the logic:iterate and print 3 html coluns and change line, something like this (modulos is a Vector): <%int rest=0;%> <logic:iterate id="listModulos" name="modulos" indexId="index" > <% int line = index.intValue() % 3; %> <%=line%> <logic:equal parameter="<%=line%>" value="<%=rest%>" > <br> Printed <here I'll get attribute of my bean>! </logic:equal> <logic:notEqual parameter="<%=line%>" value="<%=rest%>" > Printed <here I'll get attribute of my bean>!! </logic:notEqual> </logic:iterate> If someone have other ideia to make it with logic:iterate .... cheers Daniel S.
|
 |
Detlev Detleffsen
Greenhorn
Joined: Jun 01, 2004
Posts: 1
|
|
maybe this answer appears somewhat late, but I was just having the same problem and my solution is. <%int rest=0;%> <logic:iterate id="listModulos" name="modulos" indexId="index" > <% request.setAttribute("line", new Integer(index.intValue()%3)); %> <logic:equal name="line" value="<%=rest%>" > <br> Printed <here I'll get attribute of my bean>! </logic:equal> <logic:notEqual name="line" value="<%=rest%>" > Printed <here I'll get attribute of my bean>!! </logic:notEqual> </logic:iterate>
|
 |
 |
|
|
subject: logic:equal
|
|
|