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

Question in Facelets

 
Kumar Saravanan
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic