Strange Behaviour: Datatable and Rerendering
israel.bgf Sep 21, 2009 1:34 PMHi, i found an strange behavior and wanted to know if it's a bug or maybe something that I do not understand pretty well about reRendering on iteration components.
I have a table inside an column of another datatable, in that same column i have a button that triggers a reRender to a a4j:outputPanel, but when i click that button the value of the dataTable get evaluated again, even that i do not "rerendered" that region (ok that was very strange to understand). Here is the sample code (Seam 2.2.0, RichFaces 3.3.1)
Bean.class
-----
@Name("bean") @Scope(ScopeType.PAGE) public class Bean { private List<String> list; @Create public void init(){ list = new ArrayList<String>(); list.add("1"); } public double random(){ return Math.random(); } public List<String> generateList(){ System.out.println("Darn! I shouldn't be invoked!"); return new ArrayList<String>(); } public List<String> getList() { return list; } public void setList(List<String> list) { this.list = list; } }
test.xhtml
----------
<?xml version="1.0" encoding="ISO-8859-1" ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j" xmlns:s="http://jboss.com/products/seam/taglib"> <body> <a4j:form> <rich:dataTable value="#{bean.list}"> <rich:column> <f:facet name="header"> Column </f:facet> <a4j:commandButton value="ReRender panelOne!" reRender="panelOne" ajaxSingle="true"/> <br/> <a4j:outputPanel id="panelOne"> This is the panelOne: #{bean.random()} </a4j:outputPanel> <br/> <a4j:outputPanel id="cursedPanel"> This is the panelTwo: #{bean.random()} <rich:dataTable value="#{bean.generateList()}"> <rich:column> blabla... </rich:column> </rich:dataTable> </a4j:outputPanel> </rich:column> </rich:dataTable> </a4j:form> </body> </html>
Clicking in the test button should rerender only the "panelOne", and it happens as the new random number appears. But the strange thing is that the generateList() method is called again (the sysout print its message) and even stranger is the fact that the random number of the panelTwo do not get "randomized" (as the panel is not a reRender target of the button).
Is that normal?
Thanks in advance,
Israel