jsf - Controlling component from backing bean -
i want 'update' component new component in bean.
xhtml
<composite:interface> <composite:attribute name="rootkey" required="true" /> <composite:attribute name="id" required="true" /> </composite:interface> <composite:implementation> <rich:panel id="#{cc.attrs.id}" binding="#{mybean.custompanel}"/> <a4j:jsfunction name="createpanels" action="#{mybean.createpanels}" render="#{cc.attrs.id}"> <a4j:param name="rootid" assignto="#{mybean.rootid}"/> <a4j:param name="rootkey" assignto="#{mybean.rootkey}"/> </a4j:jsfunction> <script type="text/javascript"> /* <![cdata[ */ jquery(document).ready(function() { createpanels('#{cc.attrs.id}','#{cc.attrs.rootkey}'); }); /*]]> */ </script> </composite:implementation> </ui:composition> bean
private uipanel rootpanel; public void setcustompanel(uipanel panel) { rootpanel = panel; } public uipanel getcustompanel() { return rootpanel; } public void createpanels() { //try #1 : adding new panels children rootpanel.getchildren().add((uipanel)createpanels(rootid,rootkey)); //try #2 : new panel component rootpanel = (uipanel)createpanels(rootid,rootkey); ... rootpanel.setid(rootid); // id same 'placeholder' panelid facescontext.getcurrentinstance().getpartialviewcontext().getrenderids().add(rootpanel.getid()); // rerender should done in xhtml js function. } with debugger see rootpanel changes new panel component, not in view. miss?
what try in short: generating dynamically components children panel component in xhtml view. generation needs 'rootkey' param generating right set.
using:
- jsf mojarra 2.1.19
- richfaces
the solution me rerender te parent, not actual component. adding new element children children bound component.
xhtml : added h:panelgroup around place holder.
<h:panelgroup id="#{cc.attrs.id}_parent"> <rich:panel id="#{cc.attrs.id}" binding="#{mybean.panel}"/> </h:panelgroup> <a4j:jsfunction name="createpanels" action="#{mybean.createpanels}" render="#{cc.attrs.id}_parent"> <a4j:param name="rootid" assignto="#{mybean.rootid}"/> <a4j:param name="rootkey" assignto="#{mybean.rootkey}"/> </a4j:jsfunction> bean : try #1 right one.
public void createpanels() { uipanel newpanel = (uipanel)createpanels(rootid,rootkey); if(newpanel.getchildcount() >= 1){ rootpanel.getchildren().addall(newpanel.getchildren()); rootpanel.setstyleclass(newpanel.getstyleclass()); rootpanel.setheader(newpanel.getheader()); } }
Comments
Post a Comment