Primefaces ajax update component in another component on dialog -


when using ajax inside selectonemenu update selectonemenu, ajax feature isn't working. what's wrong code?

this code works don't want update form.

<p:dialog header="create new campaign" height="auto" appendto="@(body)" modal="true" widgetvar="createcampaign" resizable="false">         <h:form id="createcampaign">             <h:panelgrid columns="2" cellpadding="3" cellspacing="3" style="width: 400px; max-height: 500px;" >                 <h:outputlabel value="name:" for="name" />                 <p:inputtext  style="width:90%" id="name" value="#{testbean.name}" title=" name" required="true">                 </p:inputtext>                  <h:outputlabel value="assign to:" for="assignto" />                 <p:selectonemenu  style="width:90%" id="assignto" value="#{testbean.city}">                     <f:selectitem itemlabel="choose one" itemvalue="" />                     <f:selectitems value="#{teststaticselectbean.cities}" />                     <p:ajax event="change" listener="#{testbean.control}" update="createcampaign"/>                 </p:selectonemenu>                  <h:outputlabel value="entities:" rendered="#{testbean.entitycontrol}"  id="entitieslabel"/>                 <p:selectonemenu  style="width:90%" id="entities" value="#{testbean.entity}" rendered="#{testbean.entitycontrol}">                     <f:selectitem itemlabel="choose one" itemvalue="" />                     <f:selectitems value="#{testsubselectbean.entities}" />                 </p:selectonemenu>                                 </h:panelgrid>             <br />             <p:commandbutton update="create" value="save" icon="ui-icon-check" actionlistener="#{testbean.test}" oncomplete="window.location.reload();"/>         </h:form>     </p:dialog> 

when city choosed update entities, show entities , entitieslabel. tried not work.

<p:dialog header="create new campaign" height="auto" appendto="@(body)" modal="true" widgetvar="createcampaign" resizable="false">         <h:form id="createcampaign">             <h:panelgrid columns="2" cellpadding="3" cellspacing="3" style="width: 400px; max-height: 500px;" >                 <h:outputlabel value="name:" for="name" />                 <p:inputtext  style="width:90%" id="name" value="#{testbean.name}" title=" name" required="true">                 </p:inputtext>                  <h:outputlabel value="assign to:" for="assignto" />                 <p:selectonemenu  style="width:90%" id="assignto" value="#{testbean.city}">                     <f:selectitem itemlabel="choose one" itemvalue="" />                     <f:selectitems value="#{teststaticselectbean.cities}" />                     <p:ajax event="change" listener="#{testbean.control}" update=":createcampaign:entities :createcampaign:entities"/>                 </p:selectonemenu>                  <h:outputlabel value="entities:" rendered="#{testbean.entitycontrol}"  id="entitieslabel"/>                 <p:selectonemenu  style="width:90%" id="entities" value="#{testbean.entity}" rendered="#{testbean.entitycontrol}">                     <f:selectitem itemlabel="choose one" itemvalue="" />                     <f:selectitems value="#{testsubselectbean.entities}" />                 </p:selectonemenu>                                 </h:panelgrid>             <br />             <p:commandbutton update="create" value="save" icon="ui-icon-check" actionlistener="#{testbean.test}" oncomplete="window.location.reload();"/>         </h:form>     </p:dialog> 

i assume checked testbean.control() being fired.

since p:selectonemenu id="entities" not rendered @ moment dom tree built, not available targeted update of ajax, because isn't there. need surround container, example p:outputpanel , update container instead.

something this:

<p:ajax event="change" listener="#{testbean.control}" update="createcampaign:panel1"/>  <p:outputpanel id ="panel1">       <h:outputlabel value="entities:" rendered="#{testbean.entitycontrol}"  id="entitieslabel"/>       <p:selectonemenu  style="width:90%" id="entities" value="#{testbean.entity}" rendered="#{testbean.entitycontrol}">              <f:selectitem itemlabel="choose one" itemvalue="" />              <f:selectitems value="#{testsubselectbean.entities}" />        </p:selectonemenu>    </p:outputpanel> 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -