Hi Simon,

as you already have noticed, a component binding is not the right place to get the value of a component. The reason is simple: on a postback (submit) the component binding setter is called in the restore view phase where the value of the component is not yet set. In this phase not even the submitted value is yet set for the component.

On the first submit the value is set after your setter was called. Therefore you can't see it before the second submit.

If you are interested you can have a look at [1] for details (I assume you speak german).

regards
Michael

[1]: http://jsfatwork.irian.at/semistatic/jsf.html#idx:/jsf.html:2.6

Am 25.01.2010 14:35, schrieb schneidc:

Hi,

I tried both drop down menus, MyFaces's HtmlSelectOneMenu and Trinidad's
SelectOneChoice and both seem to have the same problem or at least I can't
understand their behaviour.

The menus are bound to an according object in a managed bean and the setter
looks like this:

        public void setSelectOne(CoreSelectOneChoice selectOne) {
                this.selectOne = selectOne;
                if(selectOne.getValue() != null)
                        System.out.println(selectOne.getValue().toString());
                else
                        System.out.println("broker null");
        }

the tags:

                        <tr:selectOneChoice id="menu0" inlineStyle="margin-left: 
20px"
binding="#{createTransactionModel.selectOne}">
                                <tr:selectItem label="Broker" value="broker" />
                                <tr:selectItem label="Customer" value="customer" 
/>
                        </tr:selectOneChoice>

The very first time I call a page I get "broker null" as expected. Then I
push a button which causes a submit and the setter get's called again but
although I SELECTED a value I still get "broker null". When I push the
button a second time I finally get a not null value.


And if it wasn't confusing enough the behaviour differs from App Server to
App Server. The above behaviour was observed on a Websphere App Server. On a
Glassfish instead I get "broker null" when the page is called for the first
time (ok so far) and when I hit a button
"broker null"
"broker != null"
as output straight one after another.


Can somebody explain to me this behaviour? Especially why I only get a not
null value on the WAS after causing a submit a second time?


Cheers
Simon

Reply via email to