Solved

Struts - <logic:iterate> problem

Posted on 2004-08-31
8
318 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 175 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

911 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

17 Experts available now in Live!

Get 1:1 Help Now