Solved

Problem with Struts JSP logic:equal tag code

Posted on 2004-08-10
4
3,547 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
  • 2
4 Comments
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Veeam Backup & Replication has added a new integration – Veeam Backup for Microsoft Office 365.  In this blog, we will discuss how you can benefit from Office 365 email backup with the Veeam’s new product and try to shed some light on the needs and …
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now