jsf - How to render a p:panel, triggered from the choice of a p:selectonemenu? -
i using primefaces 3.4 , jsf 2.1 , trying have p:panel item appear , dissapear regarding choices of p:oneselectmenu
. have p:datatable
inside panel want appear , populated dynamically , why using panel. datatable thing works panel no. tried linking "rendered" option on panel variable changes change of every selection of menu nothing happened. tried p:outputpanel
nothing happened. tried using button same actions again failed. code:
<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:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"> <h:body> <ui:composition template="/template.xhtml"> <ui:define name="title"> #{msg.teaching}: #{msg.socialsecurity} </ui:define> <ui:define name="body"> <h:form id="form"> <p:messages id="messages" autoupdate="true"/> <p:panel id="selectsocialsecuritypanel" rendered="true"> <p:panelgrid> <p:row> <p:column> <p:selectonemenu value="#{selectonemenusocialsecurityteachingbean.choice}"> <p:ajax update="socialsecuritydatatablepanel, socialsecuritydatatable, toupdate" listener="#{datatablesocialsecuritybean.updatetable()}"/> <f:selectitem itemlabel="#{msg.select}" itemvalue=""/> <f:selectitems value="#{selectonemenusocialsecurityteachingbean.socialsecurityteachinglist}"/> </p:selectonemenu> </p:column> <p:column> <p:commandbutton value="#{msg.find}" actionlistener="#{datatablesocialsecuritybean.updatetable()}" update="socialsecuritydatatablepanel, socialsecuritydatatable, toupdate" id="button"> <f:ajax render="toupdate"/> </p:commandbutton> </p:column> </p:row> </p:panelgrid> </p:panel> <p:outputpanel id="toupdate" rendered="#{datatablesocialsecuritybean.rendered}" autoupdate="true"> <p:panel id="socialsecuritydatatablepanel"> <p:datatable id="socialsecuritydatatable" var="unit" value="#{datatablesocialsecuritybean.socialsecuritylist}"> <p:columns value="#{datatablesocialsecuritybean.columns}" var="column" columnindexvar="colindex"> <f:facet name="header"> #{column.header} </f:facet> #{unit[column.property]} </p:columns> </p:datatable> </p:panel> </p:outputpanel> </h:form> </ui:define> </ui:composition> </h:body>
and this:
@managedbean @viewscoped public final class datatablesocialsecuritybean implements serializable { private string choice; private list<unit> socialsecuritylist; private boolean rendered; private list<columnmodel> columns = new arraylist<columnmodel>(); public boolean getrendered(){ system.out.println("datatablesocialsecuritybean getrendered"); system.out.println("datatablesocialsecuritybean getrendered="+rendered); return rendered; } public void updatetable() { rendered=true; socialsecuritylist = new arraylist<unit>(); createdynamiccolumns(); populatedatatable(socialsecuritylist); } }
any ideas?
your rendered
field false
panel not rendered on first view. in view on initial html there not tag id toupdate
can't rendered. suggest put panel
inside h:panelgroup
, rerender component:
<h:panelgroup id="mycontainer" layout="block"> <p:outputpanel id="toupdate" rendered="#{datatablesocialsecuritybean.rendered}" autoupdate="true"> </p:outputpanel> </h:panelgroup>
and use render="mycontainer"
. suggest use p:ajax
instead of f:ajax
primefaces components.
you can try adding effect adding p:effect
component child of p:outputpanel
:
<p:effect type="explode" event="load"/>
for full list of events see primefaces users guide.
Comments
Post a Comment