Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

caching issue of c:forEach in JSF  RSS feed

 
Atul Samnerkar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to display list from the ArrayList on the JSF page. I have used JSTL c:forEach to display the data.

The applicaiton is of 2 screens. On the first screen user selects a product from drop down and on second page, the corresponding versions of the products are displayed with the help of JSTL. The second page has hyperlink to go back to first page, if user wants to change the selected product.

The application runs fine for the first iteration. However, from second iteration onwards, (when user goes back to first page from second page) it displays the versions of the old product. When the data is printed in log from the backend bean, it displays the updated records. Somewhere the data is getting cached in c:forEach. Does any one knows any solution to this?

<c:forEach items="${beanRef.verArrayList}" var="kmorder">
<li>${kmorder}</li>
</c:forEach>


Thanks,
Atul Samnerkar
[ October 01, 2008: Message edited by: Atul Samnerkar ]
 
Himanshu Gupta
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show the code of your backing bean too.

Are you clearing the ArrayList after every request?
 
Atul Samnerkar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


verArrayList.size is printed correctly from the backend bean.
 
Himanshu Gupta
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to check it using firebug or see the source of the page generated. Try to clean the arraylist in the page itself or try to use some JSF componenet itself.
 
Tim Holloway
Bartender
Posts: 18705
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSTL should be an option of last resort when using JSF. It doesn't always mesh well with the JSF infrastructure and it violates a fundamental tenet of the JSF philosophy: keeping the Controller logic and View (JSF page) separate from each other.
 
Atul Samnerkar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The list needs to be shown in the bulleted format. Is there any way that i can use any JSF component to do this? If not, then i have to use outputText and form the bullted list in StringBuffer and then set it to the outputText.

Being formating of the content is the part of view, i dont want it to be part of backend bean. Hence i opted for the JSTL.

However, if i dont have any option, then i have to build this UI logic in the backend bean and dispay the content using JSF component - outputText.

Thanks & Regards,
Atul Samnerkar
 
Himanshu Gupta
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can simply use of data table with one column containing image and the other column contains the Data.
 
Atul Samnerkar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Himanshu.

I tried below way and it helped me.



Thanks & Regards,
Atul Samnerkar
[ October 01, 2008: Message edited by: Atul Samnerkar ]
 
Atul Samnerkar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have added li tag before and after the outputtext and its working fine. However, it is not displayed on this forum for some reason. I tried to edit the code twice and no Luck...

Thanks,
Atul Samnerkar
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!