Link to home
Start Free TrialLog in
Avatar of sangeetha
sangeetha

asked on

Struts - <logic:iterate> problem

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.
Avatar of girionis
girionis
Flag of Greece image

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.

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>
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>
Avatar of sangeetha
sangeetha

ASKER

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.
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.
ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Have you tried my code? Does it work?