JSF selectOneButton with ajax update - setter 2 times invoked

ajax, java, jsf-2, primefaces

Solution

Likely what you are seeing is that the managed bean `graph` is being instantiated early in the JSF lifecycle, and only later in the `APPLY_REQUEST_VALUES` phase is the appropriate value being set for the managed property `view`. The managed bean regardless of scope, will be reinstantiated after each request due to the inherently stateless nature of the web.

For more information, BalusC has a great article on debugging the JSF Lifecycle with a step-by-step walkthrough on how to implement a custom PhaseListener that will help you understand and debug behavior like this in your application.

http://balusc.blogspot.com/2006/09/debug-jsf-lifecycle.html

Problem

I use Primefaces 3.2 with ApacheMyfaces on WebSphere Application Server 8. I have a selectOneButton with an ajax update inside. When I switch the button, my setter firsts sets the value (int) to 0 and then to the value which is selected: ``` <p:selectOneButton value="#{graph.view}" id="view"> <f:selectItem itemLabel="W" itemValue="1" /> <f:selectItem itemLabel="M" itemValue="2" /> <f:selectItem itemLabel="Y" itemValue="3" /> <p:ajax event="change" update=":optform:datecol"/> </p:selectOneButton> ``` datecol is another selectComponent inside my form (optform). Why does JSF first set the value to 0 and then to e.g. 2? SOLUTION It is a PrimeFaces selectOneButton Bug. See My question here . Best Regards Veote

Original source