Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're basically abusing the <code>valueChangeListener</code> here. You're not exactly interested in the value change (i.e. you aren't interested in <strong>both</strong> the old and new value), you're only interested in the submitted value. This was tolerated in JSF 1.x when you didn't/can't/won't use an ajax based component library. There are (rather complicated) ways to fix your particular problem with the <code>valueChangeListener</code>, but in JSF 2.x, which ships with builtin ajax capabilities, this really can't be done that way anymore. You should rather use the <code>&lt;f:ajax&gt;</code> tag to introduce asynchronous submits and partial updates.</p> <p>Rewrite your view as follows:</p> <pre class="lang-html prettyprint-override"><code>Formula name: &lt;h:inputText value="#{output.formulaName}" id="formulaName" /&gt; &lt;br/&gt;&lt;br/&gt; The formula so far: &lt;h:inputTextarea id="formula" value="#{output.propertyReferenceValue}#{output.property2ReferenceValue}"&gt;&lt;/h:inputTextarea&gt; &lt;br/&gt;&lt;br/&gt; Property1: &lt;h:selectOneMenu value="#{output.propertyReferenceValue}" id="selectTwo"&gt; &lt;f:selectItems value="#{property.propertyReference}"/&gt; &lt;f:ajax render="formula" /&gt; &lt;/h:selectOneMenu&gt; &lt;br/&gt;&lt;br/&gt; Property2: &lt;h:selectOneMenu value ="#{output.property2ReferenceValue}" id="selectThree"&gt; &lt;f:selectItems value="#{property2.property2Refference}" /&gt; &lt;f:ajax render="formula" /&gt; &lt;/h:selectOneMenu&gt; </code></pre> <p>That's all. Your <code>#{output}</code> bean should be put in the view scope by <code>@ViewScoped</code>. No addidional listener methods are necessary. Only if you ever want to manipulate the values before displaying it, then you need an ajax listener. E.g.</p> <pre class="lang-html prettyprint-override"><code>Formula name: &lt;h:inputText value="#{output.formulaName}" id="formulaName" /&gt; &lt;br/&gt;&lt;br/&gt; The formula so far: &lt;h:inputTextarea id="formula" value="#{output.formula}"&gt;&lt;/h:inputTextarea&gt; &lt;br/&gt;&lt;br/&gt; Property1: &lt;h:selectOneMenu value="#{output.propertyReferenceValue}" id="selectTwo"&gt; &lt;f:selectItems value="#{property.propertyReference}"/&gt; &lt;f:ajax listener="#{output.calculateFormula}" render="formula" /&gt; &lt;/h:selectOneMenu&gt; &lt;br/&gt;&lt;br/&gt; Property2: &lt;h:selectOneMenu value ="#{output.property2ReferenceValue}" id="selectThree"&gt; &lt;f:selectItems value="#{property2.property2Refference}" /&gt; &lt;f:ajax listener="#{output.calculateFormula}" render="formula" /&gt; &lt;/h:selectOneMenu&gt; </code></pre> <p>with e.g. (this kickoff example does a simple concatenation on comma, you've however the full freedom to build the <code>formula</code> value the way you want):</p> <pre><code>public void calculateFormula() { formula = propertyReferenceValue + ", " + property2ReferenceValue; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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