Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem with Struts JSP logic:equal tag code

Posted on 2004-08-10
4
Medium Priority
?
3,592 Views
Last Modified: 2012-06-27
We are writing a new Struts (1.1) based web application.  One of the JSP's we are writing requires us to display a table of business check information.  A code snippet follows:

*****

    <tr>
        <td colspan="2" valign="top" nowrap>
        <table>
            <logic:iterate collection="<%=checks%>"
                   id="check"
         type="com.health.portal.vo.CheckSummaryVO"
         indexId="counter" >
                     <jsp:getProperty name="check" property="checkNumber" />
                    <jsp:getProperty name="check" property="checkDate" />
                    <jsp:getProperty name="check" property="checkVoidDate" />

                <logic:equal property="(counter.intValue()%3)" value="0">
                    </tr>
                    <tr>
                </logic:equal>
           
             </logic:iterate>      
         </table>
        </td>
    </tr>

*****
The problem I am having is with the logic:equal statement.  What I am trying to do is use the collection index (counter), perform a reminder operation on it, and after I have written 3 columns start a new table row.  The problem is I cannot seem to get the logic:equal statement formatted correctly.  I keep getting different JSP compile errors.  What is the correct way to write this?  Do I use property=, or name=, etc.  Or do I have to do something else entirely?

Thanks in advance!

Environment:
Java JDK v1.3.1_11
Tomcat v3.3a
Struts 1.1
On Windows XP Professional
0
Comment
Question by:mbeede
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 11766463
I would use JSTL (which could be tricky as you have such an old version of Tomcat), or in native JSP code:

    <tr>
        <td colspan="2" valign="top" nowrap>
        <table>
            <logic:iterate collection="<%=checks%>"
                   id="check"
        type="com.health.portal.vo.CheckSummaryVO"
        indexId="counter" >
                   <jsp:getProperty name="check" property="checkNumber" />
                  <jsp:getProperty name="check" property="checkDate" />
                  <jsp:getProperty name="check" property="checkVoidDate" />

                <% if( ( counter.intValue() % 3 ) == 0 ) { %>
                    </tr>
                    <tr>
                <% } %>
           
             </logic:iterate>    
         </table>
        </td>
    </tr>
0
 

Author Comment

by:mbeede
ID: 11766568
I appreciate your quick response on this.  I got it working this way too.  However, can it be done using a logic:equal tag, or another kind of logic:? tag specifically?  Our project lead wants us to use tags as much as possible.  Example please!

Thanks again!
0
 
LVL 35

Accepted Solution

by:
TimYates earned 2000 total points
ID: 11766626
I don't think logic:equal accepts evaluations as parameters...

I don't think it does...maybe someone can prove me wrong (I hope so, as it will simplify loads of my code) ;-)

As I said, there are the JSTL tags, which have things like c:test (which I think you would need here), but I haven't really used them myself...And I'm not sure they will work with Tomcat3

I will have a search about tomorrow if no-one else has solved this for you,   I have to take the gf to the pub ;-)

Good luck with it!!

Tim

http://java.sun.com/webservices/docs/1.0/tutorial/doc/JSTL.html
http://java.sun.com/webservices/docs/1.0/tutorial/doc/JSTL5.html#74001
0
 
LVL 9

Expert Comment

by:nimaig
ID: 11769884
Tim is correct. <logic:equal> don't accepts evaluations as parameters.
If you need to use only struts tag you can do the following.

<tr>
        <td colspan="2" valign="top" nowrap>
        <table>
            <logic:iterate collection="<%=checks%>"
                   id="check"
        type="com.health.portal.vo.CheckSummaryVO"
        indexId="counter" >
                   <jsp:getProperty name="check" property="checkNumber" />
                  <jsp:getProperty name="check" property="checkDate" />
                  <jsp:getProperty name="check" property="checkVoidDate" />

                <bean:define id="myCondition" value="<%=String.valueOf(counter.intValue()%3)%>"/>
                <logic:equal name="myCondition" value="0">
                    </tr>
                    <tr>
                </logic:equal>
           
             </logic:iterate>    
         </table>
        </td>
    </tr>

 
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An overview of cyber security, cyber crime, and personal protection against hackers. Includes a brief summary of the Equifax breach and why everyone should be aware of it. Other subjects include: how cyber security has failed to advance with technol…
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question