dynamic - Conditional jsf include -


how can conditionally include jsf facelets file @ runtime? sample functionality required

if ( add button click) {  ui:include src="add.xhtml" }  if ( update button click) {  ui:include src="update.xhtml" } 

the syntax above indicative ...

mojarra 2.1.1 / apache tomcat 7.0.22 / primefaces 3.4

ui:include doesn't have rendered attribute have encapsulate in other component. set property on server base on button clicked.

<h:form>   <p:commandbutton value="add" update=":includecontainer">     <f:setpropertyactionlistener value="add" target="#{mybean.action}"/>   </p:commandbutton>   <p:commandbutton value="update" update=":includecontainer">     <f:setpropertyactionlistener value="update" target="#{mybean.action}"/>   </p:commandbutton> </h:form>  <h:panelgroup id="includecontainer">   <h:panelgroup rendered="#{mybean.action == 'add'}">     <ui:include src="add.xhtml"/>   </h:panelgroup>   <h:panelgroup rendered="#{mybean.action == 'update'}">     <ui:include src="update.xhtml"/>   </h:panelgroup> </h:panelgroup> 

in backing bean have getter , setter:

public void setaction(string action) {   this.action = action; }  public string getaction() {   return action; } 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -