Solved

Struts - <logic:iterate> problem

Posted on 2004-08-31
8
314 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

706 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

20 Experts available now in Live!

Get 1:1 Help Now