?
Solved

Problem with Struts JSP logic:equal tag code

Posted on 2004-08-10
4
Medium Priority
?
3,588 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

New style of hardware planning for Microsoft Exchange server.
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

777 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