Hello!
I want to create some part of my page from the code. So I create on the page container (h:panelGroup) and bind it to backing bean in the request scope. Than I create a builder method that add children components to this panelGroup.Formerly I called this builder method from action methods within the page and all worked ok, the area inside the container is populated with components form the code. But now I need to show this page whit dynamic components from the another page by a link. And I get a problem, because on clicking the link on the second page I'd like to populate the dynamic area and call the builder method, but it can't add children components because the binding component is null, here my simplified code:

page1.xhtml
<h:panelGroup binding="bean1.panel"/>

public class Bean1 {
private HtmlPanelGroup panel;
HtmlPanelGroup  getPanel();
void setPanel(HtmlPanelGroup  panel);

public void build() {
   panel.getChildren().clear();
   panel.getChildren().add(new HtmlOutputText());
   ...
}

page1.xhtml
<h:commandLink action="page1" value="Page 1" actionListener="#{bean2.processAction}"

public class Bean2 {
   private Bean1 bean1;
   void setBean1(Bean1 bean1);

   public String processAction(ActionEvent event)
bean1.build(); // This doesn't work cause bena1.panel is null till page1 RestoreView process
      return "page1";
   }
}

So my question is where it is correct to call such builder methods or maybe there is the standard way for creating components dynamically?

PS I tried to call build() method from setPanel(HtmlPanelGroup panel) but it seams not very elegant solution, and also have its drawbacks (e.g. when build() demand values from updated model)

Thank you for any your thoughts,
Alexey

Reply via email to