TabView's tab rendering state problem

UI Components for JSF
Post Reply
Jérôme Jadoulle
Posts: 8
Joined: 03 Feb 2011, 10:48

20 Apr 2011, 15:20

Hello,

I have a somewhat advanced problem with the Tabview as written in Primefaces v2.2.1.
Fact is that I have a Tabview with a static number of tabs (7 in my case). All these tabs are rendered (or not) depending on a backing bean property.
the Tabview component looks all fine and stuff and my sub tabs are indeed displayed or hidden as I would expect.

My problem is that I have realized that the tabs, even if their "rendered" property is set to false, are still added to the component tree, with their specific "rendered" attribute set to false.

to make it clear, from this code:
<p:tab title="shatever" rendered="false">
// some code here
</p:tab>

Primefaces adds this to the component tree:
<Tab id="j_idt234" inView="true" rendered="true" transient="false">

The problem is that if the content displays, let's say, a table with data coming from the database, sql queries will be issued to fetch the data (this is just an example) even if the tab is not displayed.
Adding a FileUpload component in the mix, forcing a processing the complete view (or so it seems) since no "process" parameter seems to be available, and all my undisplayed tabs' content is recalculated and refreshed over and over.

Are you aware of this fact? Is it a problem or should I use the TabView in another way?
Note finally that I have tried setting "dynamic" to "true" to the tabview but it didn't change anything (which is quite weird).

Thank you very much in advance for your help!
Glassfish v3.1
primefaces-2.2.1

Jérôme Jadoulle
Posts: 8
Joined: 03 Feb 2011, 10:48

20 Apr 2011, 15:49

Going further on my tests, I noted that when "dynamic" property is set to "true" in the TabView, *all* the tabs are refreshed instead of only the one I click on.
So it is even worse than the " dynamic='false' " version performance-wise since the latter refreshes all the tabs but only when I first arrive on the page.

Concerning the FileUpload I was speaking about in the example, as it does not provide the "process" attribute, the complete view gets processed (default) and (I suppose), for this reason, all my tabs content is refreshed anew.
Glassfish v3.1
primefaces-2.2.1

voyagerx
Posts: 70
Joined: 10 Feb 2011, 03:52

04 Dec 2011, 06:41

I was doing some performance testing and realized that with TabView dynamic=true, and cache=false, the backing bean methods for all content within all abs are called regardless of whether it is the active tab or not on every tab click/change. Since I am using tabs based on a data model that could allow the user to have a large number of tabs, each with large datasets within them, this could cause performance issue. Right now, I have worked around this in my tabs by wrapping everything in the tab in a panelgroup with a rendered attribute that only renders if it's the active tab.

This has made about a 60-70% increase in my performance testing when switching and viewing tabs(obviously your mileage would vary based on number of tabs and complexity within).

voyagerx
Posts: 70
Joined: 10 Feb 2011, 03:52

04 Dec 2011, 08:29

Building from SVN tonight, my suggestion above still works, but I noticed something new. Now when I click on a new tab, TabView rerenders the current tab I am on, then switches the active index, and then renders the new page I switched to.

Using a rendered attribute in a panelgroup inside a Tab still prevents all other tabs from having their backing bean methods called, but now it will call them for at least the current tab and the new tab, whereas it only called it for the new tab prior to tonight.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 29 guests