jsf - PrimeFaces binding doesn't update form -
this question has answer here:
i'm approaching jsf binding argument in primefaces.
this form:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"> <h:head> <h1 class="title ui-widget-header ui-corner-all"> <p:spacer width="100" height="10" /> primefaces test binding </h1> <title><ui:insert name="title">primefaces test</ui:insert></title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> </h:head> <h:body> <h:form id="form1"> <h:panelgroup binding="#{bindingtestclass.panelgroup}" /> </h:form> </h:body> </html> and that's body:
@managedbean(name="bindingtestclass") @viewscoped public class bindingtestclass implements serializable{ transient htmloutputlabel testvalue = null; transient htmlselectonemenu menu = null; transient htmlpanelgroup panelgroup = null; @postconstruct private void makeup(){ menu = new htmlselectonemenu(); panelgroup = new htmlpanelgroup(); testvalue = new htmloutputlabel(); panelgroup.setid("b"); panelgroup.setlayout("block"); panelgroup.setstyleclass("grid-form"); //line 0 testvalue.setid("a"); testvalue.setvalue("basiclabel"); panelgroup.getchildren().add(testvalue); htmloutputtext linebreak = new htmloutputtext(); linebreak.setvalue("<br/>"); linebreak.setescape(false); panelgroup.getchildren().add(linebreak); menu.setid("f"); // populate drop down list uiselectitems items = new uiselectitems(); list combolist = new arraylist(); combolist.add(new selectitem("---")); for(int = 0; <10; a++){ combolist.add(new selectitem( a+1 + " test")); } items.setid("ss"); items.setvalue(combolist); menu.getchildren().add(items); //add list combobox /*this first attempt doesn't work either, change backend values menu.addvaluechangelistener(new valuelistenertest()); menu.setonchange("submit()"); */ ajaxbehavior ajaxbehavior = (ajaxbehavior) facescontext.getcurrentinstance().getapplication().createbehavior(ajaxbehavior.behavior_id); ajaxbehavior.addajaxbehaviorlistener(new customajaxlistener()); //ajaxbehavior.settransient(true); ajaxbehavior.setupdate("form1"); menu.addclientbehavior("change",ajaxbehavior); panelgroup.getchildren().add(menu); } //getters,setters public htmlpanelgroup getpanelgroup() { return panelgroup; } public htmloutputlabel gettestvalue() { return testvalue; } public void settestvalue(htmloutputlabel testvalue) { this.testvalue = testvalue; } public void setpanelgroup(htmlpanelgroup panelgroup) { this.panelgroup = panelgroup; } public htmlselectonemenu getmenu() { return menu; } public void setmenu(htmlselectonemenu menu) { this.menu = menu; } } the fact if , if put separate binding code in view way:
<h:outputlabel binding="#{bindingtestclass.testvalue}" /> and take out corresponding child panelgroup, when change selectonemenu value, listener change value in backing bean, , updates form updates indeed value of "testvalue" label.
i've tried different attempts still didn't catch why won't work in way, putting in single panelgroup.
can point me in right direction?
many many in advance!
edit: code above works @requestscoped scope , putting attributes variabile in "private" modifier mode. there's no chance @viewscoped?
binding in jsf works correctly request scope beans.
Comments
Post a Comment