?
Solved

Struts - <logic:iterate> problem

Posted on 2004-08-31
8
Medium Priority
?
348 Views
Last Modified: 2012-06-22
Hi,

Since i cannot show you how my o/p looks like, i have pasted my html below. Sorry for the length. :-(

I have this Struts - JSP:

<body>
            
            <table width="100%" border="1" cellspacing="0" cellpadding="0" id="calendar">
                  <tbody>
                  <tr class="kalenderhead" align="center">
                        <td> Team/Members </td>
                        <td> Availability </td>                  
                        <logic:iterate name="DateRange" id="Date">
                              <td> <bean:write name="Date" property="label" /> </td>
                        </logic:iterate>
                  </tr>
                  <logic:iterate name="ListView" property="abteilungenView.teamsViews" id="teams">
                  <tr>
                        <td><bean:write name="teams" property="name" /></td>
                        <td>
                              <table width="100%" border="1" cellspacing="0" cellpadding="0" id="calendar">
                                    <logic:iterate name="teams" property="sumOfMitarbeiter" id="sumsOfTeam">
                                          <tbody>
                                          <tr>
                                                <td><bean:write name="sumsOfTeam" property="name"/></td>
                                                      <logic:iterate name="sumsOfTeam" property="periodeViews" id="periods">
                                                <td><bean:write name="periods" property="sumBuchungen" /> </td>
                                                      </logic:iterate>
                                          </tr>
                                          </tbody>
                                    </logic:iterate>
                              </table>
                        </td>
                  </tr>
                  </logic:iterate>
                  </tbody>
            </table>
                                    
  </body>


If i run this JSP, i get the following HTML Format display:
--------------------------------------------------------------------
 
<html lang="de">
  <head>
    <base href="http://localhost:8080/KalendarTool/jsp/manage_list/show_kalendar_list.jsp">
  </head>
 
  <body>
            <table width="100%" border="1" cellspacing="0" cellpadding="0" id="calendar">
                  <tbody>
                  <tr class="kalenderhead" align="center">
                        <td> Team/Members </td>
                        <td> Availability </td>                  
                              <td> 20.10.2003 </td>
                              <td> 21.10.2003 </td>
                              <td> 22.10.2003 </td>
                              <td> 23.10.2003 </td>
                  </tr>
                  
                  <tr>
                        <td>Team A</td>
                        <td>
                              <table width="100%" border="1" cellspacing="0" cellpadding="0" id="calendar">
                                          <tbody>
                                          <tr>
                                                <td>normal</td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                          </tr>
                                          </tbody>
                                    
                                          <tbody>
                                          <tr>
                                                <td>reduced</td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                          </tr>
                                          </tbody>
                                    
                                          <tbody>
                                          <tr>
                                                <td>illness</td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                          </tr>
                                          </tbody>
                                    
                                          <tbody>
                                          <tr>
                                                <td>holiday</td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                          </tr>
                                          </tbody>
                              </table>
                        </td>
                  </tr>
                  
                  <tr>
                        <td>Team B</td>
                        <td>
                              <table width="100%" border="1" cellspacing="0" cellpadding="0" id="calendar">
                                    
                                          <tbody>
                                          <tr>
                                                <td>normal</td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                          </tr>
                                          </tbody>
                                    
                                          <tbody>
                                          <tr>
                                                <td>reduced</td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                          </tr>
                                          </tbody>
                                    
                                          <tbody>
                                          <tr>
                                                <td>illness</td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                          </tr>
                                          </tbody>
                                    
                                          <tbody>
                                          <tr>
                                                <td>holiday</td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                                <td>0.0 </td>
                                          </tr>
                                          </tbody>
                                    
                              </table>
                        </td>
                  </tr>
                  </tbody>
            </table>
  </body>
</html>



Within the 'Availability' column, my entire inner table comes. But, i want the inner table to span over the dates also.
(i.e. normal, reduced, illness and holiday in 'Availability' column, and every 0.0 in the 'date' column.) I hope i explained well.

Please give me a suggestion of how i should use my <logic:iterate> within <td>.

Thanks.
0
Comment
Question by:sangeetha
[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
  • 6
  • 2
8 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 11941638
Do not put them in separate table bodies. Try replacing this:

<logic:iterate name="teams" property="sumOfMitarbeiter" id="sumsOfTeam">
                                   <tbody>
                                   <tr>
                                        <td><bean:write name="sumsOfTeam" property="name"/></td>
                                             <logic:iterate name="sumsOfTeam" property="periodeViews" id="periods">
                                        <td><bean:write name="periods" property="sumBuchungen" /> </td>
                                             </logic:iterate>
                                   </tr>
                                   </tbody>
                              </logic:iterate>

with this:

     <logic:iterate name="ListView" property="abteilungenView.teamsViews" id="teams">
                    <td><bean:write name="teams" property="name" /></td>
                    <logic:iterate name="teams" property="sumOfMitarbeiter" id="sumsOfTeam">
                    <td><bean:write name="sumsOfTeam" property="name"/></td>
                        <logic:iterate name="sumsOfTeam" property="periodeViews" id="periods">
                            <td><bean:write name="periods" property="sumBuchungen" /> </td>
                       </logic:iterate>
     </logic:iterate>

and tell me if it helps.

0
 
LVL 35

Expert Comment

by:girionis
ID: 11941651
Wrong suggestion. Try to replace this:

<td><bean:write name="teams" property="name" /></td>
                    <td>
                         <table width="100%" border="1" cellspacing="0" cellpadding="0" id="calendar">
                              <logic:iterate name="teams" property="sumOfMitarbeiter" id="sumsOfTeam">
                                   <tbody>
                                   <tr>
                                        <td><bean:write name="sumsOfTeam" property="name"/></td>
                                             <logic:iterate name="sumsOfTeam" property="periodeViews" id="periods">
                                        <td><bean:write name="periods" property="sumBuchungen" /> </td>
                                             </logic:iterate>
                                   </tr>
                                   </tbody>
                              </logic:iterate>
                         </table>
                    </td>

with this:

<logic:iterate name="ListView" property="abteilungenView.teamsViews" id="teams">
                    <td><bean:write name="teams" property="name" /></td>
                    <logic:iterate name="teams" property="sumOfMitarbeiter" id="sumsOfTeam">
                    <td><bean:write name="sumsOfTeam" property="name"/></td>
                        <logic:iterate name="sumsOfTeam" property="periodeViews" id="periods">
                            <td><bean:write name="periods" property="sumBuchungen" /> </td>
                       </logic:iterate>
     </logic:iterate>
0
 
LVL 35

Expert Comment

by:girionis
ID: 11941672
Sorry, wrong again (hard to do it when you can't run the programme):

thsi is the new text you want:

                    <td><bean:write name="teams" property="name" /></td>
                    <logic:iterate name="teams" property="sumOfMitarbeiter" id="sumsOfTeam">
                    <td><bean:write name="sumsOfTeam" property="name"/></td>
                        <logic:iterate name="sumsOfTeam" property="periodeViews" id="periods">
                            <td><bean:write name="periods" property="sumBuchungen" /> </td>
                       </logic:iterate>
     </logic:iterate>
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 2

Author Comment

by:sangeetha
ID: 11941998
Does it mean i dont need an inner table ?

This is my code now:

<table width="100%" border="1" cellspacing="0" cellpadding="0" id="calendar">
                  <tbody>
                  <tr class="kalenderhead" align="center">
                        <td> Team/Members </td>
                        <td> Availability </td>                  
                        <logic:iterate name="DateRange" id="Date">
                              <td> <bean:write name="Date" property="label" /> </td>
                        </logic:iterate>
                  </tr>
                  <logic:iterate name="ListView" property="abteilungenView.teamsViews" id="teams">
                  <tr>
                        <td><bean:write name="teams" property="name" /></td>
                                    <logic:iterate name="teams" property="sumOfMitarbeiter" id="sumsOfTeam">
                                                <td><bean:write name="sumsOfTeam" property="name"/></td>
                                                <logic:iterate name="sumsOfTeam" property="periodeViews" id="periods">
                                                <td><bean:write name="periods" property="sumBuchungen" /> </td>
                                                </logic:iterate>
                                    </logic:iterate>
                                    
                  </tr>
                  </logic:iterate>
                  </tbody>
            </table>


It displays like:


Team/Members  Availability  20.10.2003  21.10.2003  22.10.2003  23.10.2003
------------------- -------------  --------------  -------------   -------------  --------------
Team A normal 0.0  0.0  0.0  0.0  reduced 0.0  0.0  0.0  0.0  illness 0.0  0.0  0.0  0.0  holiday 0.0  0.0  0.0  0.0  

Team B normal 0.0  0.0  0.0  0.0  reduced 0.0  0.0  0.0  0.0  illness 0.0  0.0  0.0  0.0  holiday 0.0  0.0  0.0  0.0  



But, i want like:


Team/Members  Availability  20.10.2003  21.10.2003  22.10.2003  23.10.2003
------------------   -----------    -------------  -------------     ------------  ---------------

                         normal           0.0              0.0             0.0                0.0  
Team A              reduced          0.0              0.0             0.0               0.0  
                         illness             0.0              0.0             0.0               0.0  
                         holiday           0.0              0.0             0.0                0.0  

                         normal           0.0              0.0             0.0                0.0  
Team B              reduced          0.0              0.0             0.0               0.0  
                         illness             0.0              0.0             0.0               0.0  
                         holiday           0.0              0.0             0.0                0.0


Thanks.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11942040
Yes you do not need an inner table. You just need to have corresponding rows and columns for the Team/Members Availability and the dates you have after that.
0
 
LVL 35

Accepted Solution

by:
girionis earned 700 total points
ID: 11942131
You need to obtain the following result:

<table width="100%" border="1" cellspacing="0" cellpadding="0" id="calendar">
                 <tr class="kalenderhead" align="center">
                    <td> Team/Members </td>
                    <td> Availability </td>              
                         <td> 20.10.2003 </td>
                         <td> 21.10.2003 </td>
                         <td> 22.10.2003 </td>
                         <td> 23.10.2003 </td>
               </tr>
               <tr>
                    <td>Team A</td>
                    <td>normal</td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
              </tr>
              <tr>
                    <td>Team B</td>
                    <td>normal</td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
              </tr>
          </table>

Try this, it should do what you are looking for:

<table width="100%" border="1" cellspacing="0" cellpadding="0" id="calendar">
      <tr class="kalenderhead" align="center">
            <td> Team/Members </td>
            <td> Availability </td>              
            <logic:iterate name="DateRange" id="Date">
            <td> <bean:write name="Date" property="label" /> </td>
            </logic:iterate>
      </tr>
      <logic:iterate name="ListView" property="abteilungenView.teamsViews" id="teams">
      <tr>
            <td><bean:write name="teams" property="name" /></td>
            <logic:iterate name="teams" property="sumOfMitarbeiter" id="sumsOfTeam">
            <td><bean:write name="sumsOfTeam" property="name"/></td>
                  <logic:iterate name="sumsOfTeam" property="periodeViews" id="periods">
                  <td><bean:write name="periods" property="sumBuchungen" /> </td>
                  </logic:iterate>
            </logic:iterate>
            </td>
      </tr>
      </logic:iterate>
</table>
0
 
LVL 2

Author Comment

by:sangeetha
ID: 11942354
girinois,

I want like this:

<html>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0" id="calendar">
                 <tr class="kalenderhead" align="center">
                    <td> Team/Members </td>
                    <td> Availability </td>              
                         <td> 20.10.2003 </td>
                         <td> 21.10.2003 </td>
                         <td> 22.10.2003 </td>
                         <td> 23.10.2003 </td>
               </tr>
               <tr>
                    <td rowspan="4">Team A</td>
                    <td>normal</td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
              </tr>
            <tr>
                    <td>reduced</td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
              </tr>
            <tr>
                    <td>illness</td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
              </tr>
            <tr>
                    <td>holiday</td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
              </tr>
               <tr>
                    <td rowspan="4">Team B</td>
                    <td>normal</td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
              </tr>
            <tr>
                    <td>reduced</td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
              </tr>
            <tr>
                    <td>illness</td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
              </tr>
            <tr>
                    <td>holiday</td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
                    <td>0.0 </td>
              </tr>
          </table>

</body>
</html>

I increased some more points. Thanks for your help.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11942793
Have you tried my code? Does it work?
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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

771 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