Remo Liechti wrote:
Hi All

THE JSF livecycle is like this
Faces Request -> Restore View -> Apply Request Values (call all the
setters) -> process events -> ...

There are two possible ways how to configure to submit a form: With a
button(and its action) or with the javascript onchange property on any
element. But the JSF Livecycles are DIFFERENT!!!

I got a setter and an event called updater. The updater uses the
variable "currentKpiGroup" which is set by the setter.


By button:
==========
<h:selectOneMenu
  id="selectedKpiGroup"
value="#{flowScope.KPIBrowserBean.currentKpiGroup}">
<f:selectItems value="#{flowScope.KPIBrowserBean.kpiGroups}" />
</h:selectOneMenu>

<h:commandButton action="#{flowScope.KPIBrowserBean.kpiGroupChanged}"
value="Change" styleClass="button" />

By onchange-property:
=====================
<h:selectOneMenu
  id="selectedKpiGroup"
value="#{flowScope.KPIBrowserBean.currentKpiGroup}"
  valueChangeListener="#{flowScope.KPIBrowserBean.kpiGroupChanged}"
  onchange="submit()">
<f:selectItems value="#{flowScope.KPIBrowserBean.kpiGroups}" />
</h:selectOneMenu>



So, everything works fine if I use the button to submit the form(console
oputput):

SETTER currentKpiGroup grp: 3
UPDATER(event) currentKpiGroup: 3

The setters are called before the events.




If I use the onchange property, the console output is this:

UPDATER(event) currentKpiGroup: 2
SETTER currentKpiGroup grp: 3

my application performs wrong because of the old
value(currentKpiGroup=2).
The event is process before the new value(currentKpiGroup=3) are set.



Does sombody know anything about this behavior? I need to submit the
form by onchange...

I'm looking forward to your answers!

Thanks,

Remo


Hello Remo,

again, I'd suggest using immediate like this:


<t:selectOneMenu
  id="selectedKpiGroup"
  immediate="true"
  value="#{flowScope.KPIBrowserBean.currentKpiGroup}"
  valueChangeListener="#{flowScope.KPIBrowserBean.kpiGroupChanged}"
  onchange="submit()">
  <f:selectItems value="#{flowScope.KPIBrowserBean.kpiGroups}" />
</t:selectOneMenu>

This is what the documentation says about immediate:

... cite from http://myfaces.apache.org/tomahawk/tlddoc/index.html
A boolean value that identifies the phase during which value change events should fire. During normal event processing, value change events are fired during the "invoke application" phase of request processing. If this attribute is set to "true", these methods are fired instead at the end of the "apply request values" phase.
... cite from http://myfaces.apache.org/tomahawk/tlddoc/index.html

Best regards

Ondrej Svetlik

Reply via email to