Hi all,
I have a List object which should be iterated in my Page.
Saw in the Tld docs that <tc:forEach/> is deprecated, and suggested to use
<c:forEach/>
Tried with <c:forEach/>,
The code looks fine, but had some issue ,
The iteration part is written in the first page after a user logs in, it has an
external link on the top navigation bar.
Initially when the user logs in , the iteration is not taking place, but the
bean exists as i am checking for its null or not.
But when i click on the link that refers to the same page, am able to see the
iterations.
The List contains 2 objects, these two objects must be iterated.
But as i see in the logs, the method is being called 4 times and object is
being returned, yet the first time it doesn't display the iterations.
Y is this happening.
Attached the code below , both JSP and Java
<tc:panel rendered="#{storefront.showImageContentBox}">
<tc:out value="Not Null"/>
<f:verbatim>
<table border="1">
</f:verbatim>
<c:forEach items="${storefront.imageContentBox}"
varStatus="content" >
<f:verbatim>
<tr valign="top">
<td width="100px">
</f:verbatim>
<tc:out value="${content.index}"/>
<f:verbatim>
</td>
<td>
</f:verbatim>
<tc:out escape="false"
value="#{storefront.imageContentBox[${content.index}].userGroupBoxImageText}"/>
<f:verbatim>
</td>
</tr>
<tr>
<td> </td>
</tr>
</f:verbatim>
</c:forEach>
<f:verbatim>
</table>
</f:verbatim>
</tc:panel>.
Java code is as such
List<CustomerContentBox> imageContentBoxes = null;
public List<CustomerContentBox> getImageContentBox(){
log.debug("getImageContentBox() methodEntry");
if (imageContentBoxes == null) {
CustomerContentBox[] customerContentBoxs =
user.getCustomerContentBox();
imageContentBoxes = new ArrayList<B2BCustomerContentBox>();
for(CustomerContentBox customerContentBox : customerContentBoxs){
imageContentBoxes.add(customerContentBox);
}
log.debug(" ImageContents Initialized, Size
::"+imageContentBoxes.size()+"\n\n");
}
return imageContentBoxes;
}
public boolean isShowImageContentBox(){
// Initialize the Image Content Boxes
getImageContentBox();
return (imageContentBoxes != null && imageContentBoxes.size() > 0);
}
This method is called 4 times as shown in the log
16:11:10,812 INFO [STDOUT] 16:11:10,812 DEBUG [StoreFrontController] getImageCo
ntentBox() methodEntry
16:11:10,828 INFO [STDOUT] 16:11:10,828 DEBUG [StoreFrontController] getImageCo
ntentBox() methodEntry
16:11:10,828 INFO [STDOUT] 16:11:10,828 DEBUG [StoreFrontController] getImageCo
ntentBox() methodEntry
16:11:10,828 INFO [STDOUT] 16:11:10,828 DEBUG [StoreFrontController] getImageCo
ntentBox() methodEntry
Any Suggestions Regarding this ?
Regards,
Madan
__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/