Search code examples
javarichfacesseam

Datatable in inactive tab in tabpanel initializes value


I just found an odd behavior within our application.

We have a rich:tabPanel switchType="ajax" with multiple tabs. Each tab contains a rich:dataTable and an edit form with a4j:form.

Now when we request the page the first tab is rendered and the datatable is initialized. So far so good. The user can now click an edit link (a4j:commandLink) to reRender the edit form with the selected entity and the form is reRendered properly.

BUT: Additionally to this we get a query from the datatables on the other tabs... Even though the tabs are not active the rich datatables get initialized. Not rendered because the tab is inactive. Strangely enough if I use a plain h:dataTable the issue goes away, i.e. no resultlist is fetched for this one.

So far I got two workarounds:

  1. If I use limitToList on the editLink it seems that the processing part is working correctly but this would mean that we have to adapt all commandbuttons/links and the global messages stops working if i do not include it's id into the reRendered attribute...

  2. I can bind the selected Tab to a backing bean and render only the content of the active tab with an s:fragment

While the second solution is quite straight forward, and I'm using this one for now, I am still seeking for an explanation.

Did anyone encounter this behavior already and has an explanation on wth is going on?

Thanks Martin


Solution

  • We do have this issue, almost all components get rendered when any ajax operation is performed.

    We resolved this issue buy adding limitRender="true" attribute to the components and by surrounding components by < a4j:outPutPanel axajRender="false"/> < rich:messages ajaxRendered="false"/>.

    However, rich:tabPanel has the attribute limitRender="true" which did not show me any difference if used or not.

    Also remember to use < a4j:queue ignoreDupResponses="true" /> as a best practice which helps optimize your Ajax requests. use this tag in forms.