jsf - How to update component on clientside in primefaces? -


i want create add children button dialog form feature.

on page there tree , modal dialog form. on every node of tree create child button. if click on create child button, there shown modal form, parentid set id of node button clicked

tree:

 <h:form id="testgrouplistform">         <p:tree value="#{testtreecontroller.root}" var="node" dynamic="true" cache="false"                       selectionmode="single"  selection="#{treebean.selectednode}" id="tree">                    <p:treenode>                       <h:outputtext value="#{node.getname()}" />  <p:commandbutton id="createbutton#{node.getidtestgroup()}" icon="ui-icon-plus"   value="#{bundle.create}"  update="tree" oncomplete="testgroupcreatedialog.show()"/>                 </p:treenode>               </p:tree>                      </h:form> 

dialog box:

        <h:form id="testgroupcreateform">              <h:panelgroup id="display">                 <p:panelgrid columns="2" >                       <p:outputlabel value="#{bundle.createtestgrouplabel_name}" for="name" />                     <p:inputtext id="name" value="#{testgroupcontroller.selected.name}" title="#{bundle.createtestgrouptitle_name}" />                     <h:inputhidden  id="parentid" value="#{testgroupcontroller.selected.parentid}" />                  </p:panelgrid>                 <p:commandbutton actionlistener="#{testgroupcontroller.savenew}" value="#{bundle.save}" update="display,:testgrouplistform:tree,:growl" oncomplete="handlesubmit(xhr,status,args,testgroupcreatedialog);"/>                 <p:commandbutton value="#{bundle.cancel}" onclick="testgroupcreatedialog.hide()"/>             </h:panelgroup>          </h:form>      </p:dialog>  

i want click on

<p:commandbutton id="createbutton#{node.getidtestgroup()}" icon="ui-icon-plus"   value="#{bundle.create}"  update="tree" oncomplete="testgroupcreatedialog.show()"/> 

will set value of:

<h:inputhidden  id="parentid" value="#{testgroupcontroller.selected.parentid}" /> 

update

i have use action listener testgroupcontroller.nodelistener set parentid of new item.

    <p:commandbutton process="@this" id="createbutton" actionlistener="#{testgroupcontroller.nodelistener}" icon="ui-icon-plus"   value="#{bundle.creategroup}"  update=":testgroupcreateform" oncomplete="testgroupcreatedialog.show()">                             <f:attribute name="rawparentid" value="#{node.getidtestgroup()}" />   </p:commandbutton> 

you can add parentid existing update= attribute so:

update="tree parentid" 

this render parentid , set value testgroupcontroller.selected.parentid.

edit

you can process values ui been too, using:

process="myinputid" 

example

<h:form>     <h:inputtext id="input"                   value="#{bean.value}" />     <h:outputtext id="output"                    value="#{bean.value}" />     <p:commandbutton process="input"                      update="output"                      value="submit" /> 

upon clicking button, value of id="input" set in bean.value (as ordered process="input"). next id="output" rendered (or updated) bean.value (as ordered update="output").


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -