Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

logic:equal

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
And then we all jump out and yell "surprise! we got you this tiny ad!"
ScroogeXHTML - fast RTF to HTML and XHTML conversion
https://coderanch.com/t/749563/ScroogeXHTML-fast-RTF-HTML-XHTML
reply
    Bookmark Topic Watch Topic
  • New Topic