You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Mikael Andersson <ma...@gmail.com> on 2006/06/08 12:03:41 UTC

Form value update headache ( via ValueChangeEvent )

Hi,
I am quite new to JSF and don't quite know how to sort out the following.

I have a page with quite a lot of forms (unholy mix of input and select
fields), the backing bean has a Spring managed object containing a all the
data that populates the form fields. I have several different beans defined
for that Spring managed object depending on which predefiend form field
values to display.

What I am trying to do is having a selectOneMeny to choose between
predefined values for the form fields, and by selecting one have a
ValueChangeEvent created which sets the Spring managed object to the
specified one. My problem is that the even though the object populating the
form fields change the form values doesn't change. ( submitting the form the
moment a selection is done, onchange="submit();" )
I know that the proper object is being set, printing its toString().

I guess this is related to the lifecylcle and the fact that apply request
values phase isn't executed?

Code for ValueChangeEvent :

public void loadCannedQuery(ValueChangeEvent e) throws
AbortProcessingException {
        log.info("In ValueChanged handler: loadCannedQuery");

        UIComponent comp = e.getComponent( );

        cannedQuery = (String)e.getNewValue();
        loadCannedQuery();
        //Skipp validations...

        ctx.renderResponse();
}

Is there some other way of by passing the validations besides calling
renderResponse() ?
Read about the valueChangeNotifier in the sandbox, but I am using Facelets
and that tag doesn't seem to work with Faclets currently.

Hope the above makes sense :)

Thanks
- Micke

Re: Form value update headache ( via ValueChangeEvent )

Posted by Mikael Andersson <ma...@gmail.com>.
I had to put that "form data chaning" dropdown outside of the form to get it
working, but I would much rather have it inside the main form "in context".

So please if anyone has a solution to my problem, I am very interested ( if
I need to clarify something please ask as well).

Micke

On 08/06/06, Mikael Andersson <ma...@gmail.com> wrote:
>
> Hi,
> I am quite new to JSF and don't quite know how to sort out the following.
>
> I have a page with quite a lot of forms (unholy mix of input and select
> fields), the backing bean has a Spring managed object containing a all the
> data that populates the form fields. I have several different beans defined
> for that Spring managed object depending on which predefiend form field
> values to display.
>
> What I am trying to do is having a selectOneMeny to choose between
> predefined values for the form fields, and by selecting one have a
> ValueChangeEvent created which sets the Spring managed object to the
> specified one. My problem is that the even though the object populating the
> form fields change the form values doesn't change. ( submitting the form the
> moment a selection is done, onchange="submit();" )
> I know that the proper object is being set, printing its toString().
>
> I guess this is related to the lifecylcle and the fact that apply request
> values phase isn't executed?
>
> Code for ValueChangeEvent :
>
> public void loadCannedQuery(ValueChangeEvent e) throws
> AbortProcessingException {
>         log.info("In ValueChanged handler: loadCannedQuery");
>
>         UIComponent comp = e.getComponent( );
>
>         cannedQuery = (String)e.getNewValue();
>         loadCannedQuery();
>         //Skipp validations...
>
>         ctx.renderResponse();
> }
>
> Is there some other way of by passing the validations besides calling
> renderResponse() ?
> Read about the valueChangeNotifier in the sandbox, but I am using Facelets
> and that tag doesn't seem to work with Faclets currently.
>
> Hope the above makes sense :)
>
> Thanks
> - Micke
>
>