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
Solved

Struts - <logic:iterate> problem

Posted on 2004-08-31
8
330 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
diffSum example 4 50
ejb on wildfly 5 30
Need Help! Getting a syntax error and don't understand why 3 31
Tagging and Merging on Branch 1 29
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

840 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