bug in rich:dataTable?
wtff Jul 1, 2007 6:05 AMHi,
I believe that the rich:dataTable component doesn't generate client-ids within the HTML/Javascript markup correctly when it is first rendered (the id of the parent naming containers are missing).
I put a a4j:commandButton within the dataTable and had it invoke a managed bean method but the method is not being invoked. If I place an h:commandLink on the same page and have it invoke the same method the method gets invoked and after that the commandButtons within the rich:dataTable rows start working correctly.
When I switch to h:dataTable everything works fine right away. I believe that this is a bug.
Here is how to reproduce it:
- I used RichFaces 3.0.1, ajax4jsf 1.1.1 and JSF-RI 1.2 on tomcat 6.0.13 and java 1.6.0-b105
put managed bean ComponentTester in application scope:
public class ComponentTester { private List<Integer> integerList = new LinkedList<Integer>(); public ComponentTester() { for(int i = 0; i < 5; i++) integerList.add(i); } public void doNothing() { System.out.println("doNothing invoked"); } public List<Integer> getIntegerList() { return integerList; } }
create page test.jsp:
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%> <%@taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%> <f:view> <a4j:page id="page"> <h:form id="form"> <h:commandLink value="submit" action="#{tester.doNothing}" /> <rich:separator /> <rich:dataTable id="table" value="#{tester.integerList}" var="item"> <rich:column><h:outputText value="#{item}"/></rich:column> <rich:column> <a4j:commandButton id="tblbutton1" value="submit" action="#{tester.doNothing}"> <a4j:ajaxListener type="org.ajax4jsf.ajax.ForceRender" /> </a4j:commandButton> </rich:column> </rich:dataTable> </h:form> </a4j:page> </f:view>
First, point the browser to the test.jsp page and click any commandButton inside the rich:dataTable. The method doNothing is not getting invoked as there is not output the the webserver-console.
Then use the h:commandLink outside the table. It will invoke the medhod correctly.
THEN try the commandButtons inside the rich:dataTable again. Now you will find that they work.
Looking at the html source, the first rendition of rich:dataTable includes client-ids in the form of:
<table ... id="table" ...>...<td ...><input id="table:0:tblbutton1" name="table:0:tblbutton1" onclick="A4J.AJAX.Submit('page','form',event,{'parameters':{'table:0:tblbutton1':'table:0:tblbutton1'} ,'actionUrl':'/web-test/faces/test.jsp'} );return false;"
invoking the h:commandLink will submit the h:form and rich:dataTable will get rerendered along with any other component on the page. This time around, rich:dataTable produces the correct client-ids:
<table ... id="form:table" ...><td ...><input id="form:table:0:tblbutton1" name="form:table:0:tblbutton1" onclick="A4J.AJAX.Submit('page','form',event,{'parameters':{'form:table:0:tblbutton1':'form:table:0:tblbutton1'} ,'actionUrl':'/web-test/faces/test.jsp'} );return false;"
I played around with this scenario a lot but couldn't get around this behaviour. It doesn't matter whether I include the ajaxListener or not.
If I replace the rich:dataTable with an h:dataTable component everything works as expected.
If I replace the h:commandLink with an a4j:commandLink the rich:dataTable won't work at all because the a4j:commandLink won't trigger a full page refresh.
Can someone shed some light on this? I believe this is a bug. I tried out varios things, like replacing h:form with aj4:form, including attributes like "prependId" on the form component but it still doesn't work.
I first wanted to paste this usecase into the user forum before submitting a bug report.
BTW: I also coudn't make use of the attribute "actionExpression". Only "action" seems to work. Can someone confirm this?
For example, if I modify the commandLink to contain the property
actionExpression="tester:doNothing" the method is not getting invoked although I am using JSF 1.2
thanks a lot
Sascha