Solved

Problem with Struts JSP logic:equal tag code

Posted on 2004-08-10
4
3,583 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Gain an elementary understanding of Blockchain technology.
Microsoft is moving in-place eDiscovery & hold from ECP to EOP console under Content Search in Search and Investigation Options.  In this post, I will be showing you how to export emails to a PST file using the Content Search Options.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 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