jsf 2 - JSF2 ui:repeat inputText wont re-render on first try -
i have ui repeat contains inputtext , command button pairs. button changes value inputtext displays , re-renders it. on first button click changes value not re-render on screen. second click same re-renders control. onevent triggers 3 status events fine. nothing shows in logs either. problem seems server side i'm using default faces setup netbeans 7.3.1.
the below code display 4 lines of inputvalue , buttons. first works fine (its outside of ui:repeat. 3 below require 2 clicks.
testbean.java
@managedbean @viewscoped public class testbean implements serializable { private myobject nc; private list<myobject> list; public testbean() { nc = null; list = new arraylist<myobject>(); } public myobject getnc() { return nc; } public void setnc(myobject nc) { this.nc = nc; } public list<myobject> getlist() { return list; } public void setlist(list<myobject> list) { this.list = list; } @postconstruct public void oninit() { myobject nc1 = new myobject(); nc1.settext("1"); list.add(nc1); myobject nc2 = new myobject(); nc2.settext("2"); list.add(nc2); myobject nc3 = new myobject(); nc3.settext("3"); list.add(nc3); myobject nc0 = new myobject(); nc0.settext("0"); nc = nc0; } }
myobject.java
public class myobject implements serializable { public string text; public myobject() { this.text = ""; } public string gettext() { return text; } public void settext(string text) { this.text = text; } public void testmethod() { text = "hey"; } }
index.xhtml
<?xml version='1.0' encoding='utf-8' ?> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"> <h:head> <title>facelet title</title> </h:head> <h:body> hello facelets<br /> <h:form> <h:inputtext id="text" readonly="true" value="#{testbean.nc.text}" /> <h:commandbutton value="test"> <f:ajax listener="#{testbean.nc.testmethod()}" execute="text" render="text" /> </h:commandbutton><br /><hr /> <ui:repeat value="#{testbean.list}" var="cur"> <h:panelgroup id="viewtest"> <h:inputtext id="text" readonly="true" value="#{cur.text}" /> </h:panelgroup> <h:commandbutton value="test"> <f:ajax listener="#{cur.testmethod()}" render="viewtest" immediate="true" /> </h:commandbutton><br /> </ui:repeat> </h:form> </h:body> </html>
i figured out. once changed .testmethod() .testmethod(ajaxbehaviorevent ae) works on first click. apparently treated differently jsf. hope else can learn mistake.
Comments
Post a Comment