File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Question in Facelets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Question in Facelets" Watch "Question in Facelets" New topic
Author

Question in Facelets

Kumar Saravanan
Ranch Hand

Joined: Aug 25, 2004
Posts: 40
Hi All,

I am using Facelets and JSF in my application.

In one of the page, am using t:dataTable to iterate over the collection. I see that my getter method was invoked 2 times since am referring it 2 times in my facelets page.

I would like to know how do I cache the collection in my facelets page so that my getter method will get invoked only one time.

I did like this in my facelets page but still my getter method invokes 2 times...

<ui:param name="var" value="#{myBean.myMethodName}"/>

and am referring the value "var" in the datatable.

Please advice what I am doing wrong or please provide how to cache the value in the Facelets so that my backing or managed bean method will be called only one time.

The reason why my method is getting referenced 2 times because am rendering the datatable only when the collection is not empty....

<t:dataTable
id="my-data-table"
forceId="true"
var="data"
value="#{myBean.myCollectionVariable}"
rendered="#{!empty myBean.myCollectionVariable}">

Thanks,
Kumar Saravanan
[ April 03, 2007: Message edited by: Kumar Saravanan ]
Fabio Lin
Greenhorn

Joined: Oct 21, 2005
Posts: 12
Usually I use dataTables through bindings instead of using value and rendered attributes.

Using binding you can populate your list, check if is empty and decide if it will show or not loading the list only once.
Kumar Saravanan
Ranch Hand

Joined: Aug 25, 2004
Posts: 40
Hi Fabio Lin,

Thanks for your reply...

I got your logic like binding the datatable to the backing bean. But If I do that it seems like tight couping between the UI code and the Backing bean code.

Is there any other way to avoid the getter method execution in a repeatable time?

Thanks,
Kumar Saravanan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question in Facelets