Note that there are some explanatory texts on larger screens.

plurals
  1. POJSF 2 f:ajax lifecycle problem
    text
    copied!<p>The problem is, that if a property is changed during an f:ajax request and a binded panelGroup should be newly created depending on that changed value, the old value is used.</p> <p>This code will explain the problem.</p> <p>Here is the backingbean TestBean:</p> <pre><code>public String getFirst() { return first; } public void setFirst(String first) { this.first = first; } public String getLast() { return last; } public void setLast(String last) { this.last = last; } public String getName(){ return first+" "+last; } public void setDynamicPanel(HtmlPanelGroup panel){ } public HtmlPanelGroup getDynamicPanel(){ Application app = FacesContext.getCurrentInstance().getApplication(); HtmlPanelGroup component = (HtmlPanelGroup)app.createComponent(HtmlPanelGroup.COMPONENT_TYPE); HtmlOutputLabel label1 = (HtmlOutputLabel)app.createComponent(HtmlOutputLabel.COMPONENT_TYPE); label1.setValue(" --&gt; "+getFirst()+" "+getLast()); component.getChildren().add(label1); return component; } </code></pre> <p>and now the jsf/facelet code:</p> <pre><code>&lt;h:form id="form"&gt; &lt;h:panelGrid columns="1"&gt; &lt;h:inputText id="first" value="#{testBean.first}" /&gt; &lt;h:inputText id="last" value="#{testBean.last}" /&gt; &lt;h:commandButton value="Show"&gt; &lt;f:ajax execute="first last" render="name dyn" /&gt; &lt;/h:commandButton&gt; &lt;/h:panelGrid&gt; &lt;h:outputText id="name" value="#{testBean.name}" /&gt; &lt;h:panelGroup id="dyn" binding="#{testBean.dynamicPanel}" /&gt; &lt;/h:form&gt; </code></pre> <p>After the page was initially loaded the outputText and panelGroup shows both "null" as first and last. But after the button is pressed, the outputText is updated well, but the the panelgroup shows again only "null". This is due to the problem, that the "binded method" dynamicPanel is executed before the update of the first and last properties. </p> <p>how can workaround this behaviour or what is wrong with my code?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload