On Mon, 07 Feb 2005 02:46:05 +0200, Dani Kenan <[EMAIL PROTECTED]> wrote:

> 
> It seems quite clear that change event handlers cannot be used together with
> value properties bound to request scope beans, since they will always be
> invoked.

JSF promises to keep the expressions for all value binding expressions
that you have set, plus values that you have set directly (not using
value bindings).  If you are expecting the framework to keep the
values that your VB expressions point at, you are expecting something
beyond what is promised.

If you want to use value change events and request scope backing
beans, you should bind the *component* into the backing bean instead
of the *value*.  This would cause the following adjustment to your
initial example:

<h:selectOneMenu id="typeName" 
  binding="#{typeListPage.typeName}" 
  valueChangeListener="#{typeListPage.onChangeTypeName}"> 
         <f:selectItems value="#{typeNameSelectItems}" />
<h:selectOneMenu> 

with the following property in your bean that "typeListPage" points at:

    private HtmlSelectOneMenu typeName = null;

    public HtmlSelectOneMenu getTypeName()
    { return this.typeName; }

    public void setTypeName(HtmlSelectOneMenu typeName)
    { this.typeName = typeName; }

In this scenario, JSF saves the value of the component across requests
(and restores the component reference by calling setTypeName() during
Restore View phase, so that value change events only fire if the value
actually changes, as you expect.

If you use value binding expressions, it is your application's
responsibility to maintain the appropriate state.

Craig McClanahan

Reply via email to