jbaisden
asked on
NESTING <LOGIC:ITERATE> <LOGIC:PRESENT> TAGS
I have a page that uses a number of tables. I also have a style sheet in that jsp page. I have one class that show's items on screen but not on print preview, and another that shows items on print preview but not the screen. I am getting an iterator error or some sort, and others times, no error at all: it simply doesn't work.
I have the following
<LOGIC:PRESENT NAME="class1">
<LOGIC:PRESENT NAME="class2">
<TABLE CLASS="NOPRINT">
<LOGIC:iterate id="class2" name="class2" indexId="ind">
<TR>
<TD>
<bean:write name='class2' property='school'/>
</TD>
</TR>
</LOGIC:ITERATE>
</TABLE>
</LOGIC:PRESENT>
</LOGIC:PRESENT>
<LOGIC:PRESENT NAME="class1">
<LOGIC:PRESENT NAME="class2">
<TABLE CLASS="NOPRINT">
<LOGIC:iterate id="class2" name="class2" indexId="ind">
<TR>
<TD>
<bean:write name='class2' property='school'/>
</TD>
</TR>
</LOGIC:ITERATE>
</TABLE>
</LOGIC:PRESENT>
</LOGIC:PRESENT>
The second section doesn't work at all. I don't know how to reset the iterator. I absolutely cannot use any <% %> tags either. I have tried splitting the sections like I did above and I have tried putting them together as follows:
<LOGIC:PRESENT NAME="class1">
<LOGIC:PRESENT NAME="class2">
<TABLE CLASS="NOPRINT">
<LOGIC:iterate id="class2" name="class2" indexId="ind">
<TR>
<TD>
<bean:write name='class2' property='school'/>
</TD>
</TR>
</LOGIC:ITERATE>
</TABLE>
<TABLE CLASS="NOPRINT">
<LOGIC:iterate id="class2" name="class2" indexId="ind">
<TR>
<TD>
<bean:write name='class2' property='school'/>
</TD>
</TR>
</LOGIC:ITERATE>
</TABLE>
</LOGIC:PRESENT>
</LOGIC:PRESENT>
I have checked the code to make sure there isn't another master <LOGIC:PRESENT> tag surrounding both the NOPRINT and NOSHOW sections. There isn't one. The only tag that encompasses both of these sections is the <BODY></BODY> tag, which I would think is appropriate.
Please help. I need a solution ASAP. Also, I don't want to duplicate objects in the session. I would really like to reuse the same object ( so I don't have to use something like classB1 or classB2 ).
Thanks in advance. Will up points depending on the promptness and completeness of solution.
I think your problem is how to reset index in the next iteration.
I would like you to test this option
<LOGIC:iterate id="class2" name="class2" indexId="ind" offset="0">
I would like you to test this option
<LOGIC:iterate id="class2" name="class2" indexId="ind" offset="0">
ASKER
I have made that modification. The error I am receiving is: Error 500: Cannot create iterator for this collection. Will continue testing.
ASKER
I still have not made any progress. Any help would be appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That did it Tim! Thanks!
:-)
Good luck!!
Tim
Good luck!!
Tim
ASKER
<LOGIC:PRESENT NAME="class1">
<LOGIC:PRESENT NAME="class2">
<TABLE CLASS="NOPRINT">
<LOGIC:iterate id="class2" name="class2" indexId="ind">
<TR>
<TD>
<bean:write name='class2' property='school'/>
</TD>
</TR>
</LOGIC:ITERATE>
</TABLE>
</LOGIC:PRESENT>
</LOGIC:PRESENT>
<LOGIC:PRESENT NAME="class1">
<LOGIC:PRESENT NAME="class2">
<TABLE CLASS="NOSHOW">
<LOGIC:iterate id="class2" name="class2" indexId="ind">
<TR>
<TD>
<bean:write name='class2' property='school'/>
</TD>
</TR>
</LOGIC:ITERATE>
</TABLE>
</LOGIC:PRESENT>
</LOGIC:PRESENT>
and the second set of code should be
<LOGIC:PRESENT NAME="class1">
<LOGIC:PRESENT NAME="class2">
<TABLE CLASS="NOPRINT">
<LOGIC:iterate id="class2" name="class2" indexId="ind">
<TR>
<TD>
<bean:write name='class2' property='school'/>
</TD>
</TR>
</LOGIC:ITERATE>
</TABLE>
<TABLE CLASS="NOPRINT">
<LOGIC:iterate id="class2" name="class2" indexId="ind">
<TR>
<TD>
<bean:write name='class2' property='school'/>
</TD>
</TR>
</LOGIC:ITERATE>
</TABLE>
</LOGIC:PRESENT>
</LOGIC:PRESENT>
For the record the syle sheet is in the header. It is as follows:
<STYLE media="print">.noprint
{
DISPLAY: none;
}</STYLE>
<STYLE media="screen">.noshow
{
DISPLAY: none;
}</STYLE>
Hope that makes it more clear.