Note that there are some explanatory texts on larger screens.

plurals
  1. POJSF getValue() v.s. getSubmittedValue()
    primarykey
    data
    text
    <p>I've been developing a few JSF applications lately and am disturbed with the inconsistency in the web component APIs. </p> <p>I've noticed that there is extremely unpredictable behavior when calling .getValue() or .getSubmittedValue() on a JSF component object in server side code. Sometimes when I call .getValue() on a drop down list box, I've noticed that I get the value as it was BEFORE I selected my value (so the value from the last page refresh), of which .getSubmittedValue() gets me the correct value, as such:</p> <pre><code>UIInput name = new UIInput(); // This is the control I have in a bean. public void submit(ActionEvent ae) { someMethod(name.getValue().toString()); // Retrieves the "old" value someMethod(name.getSubmittedValue().toString()); // Retrieves the correct value } </code></pre> <p>Also, I've noticed that calling .getSubmittedValue() on a form field sometimes results in a null pointer exception because that value has not been instantiated in the component object, in which case when I call .getValue() in that circumstance I get the correct value, for example:</p> <pre><code>HtmlInputText name = new HtmlInputText(); // This is the control I have in a bean. public void submit(ActionEvent ae) { someMethod(name.getValue().toString()); // Retrieves the correct value someMethod(name.getSubmittedValue().toString()); // Throws NullPointerException } </code></pre> <p>Is this just a "quirk" of the JSF framework, or am I just using the API <strong>COMPLETELY</strong> incorrectly?? Any insight into these two methods would be greatly appreciated. Cheers.</p>
    singulars
    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.
 

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