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/04/05 13:27:51 UTC

Advice please, updated model via valueChange event not render the way I thought

Hi all,
I am relatively new to JSF and have run into a bit of a problem and need
some advice.

I have a semi complex web form where I would like to use a selectOneMenu and
valueChange events to alter various form field values depending on what is
selected.

selectOneMenu is used like this:
<select jsfc="h:selectOneMenu" value="#{backing.params.strings['dbType']}"
onchange="this.form.submit( );" valueChangeListener="#{
backing.loadCannedQuery}" immediate="true">
      <option jsfc="f:selectItems" value="#{backing.data.mapStrStr
['dbTypes']}"/>
</select>

The loadCannedQuery method above, reloads the 'params' object with updated
values and then calls renderResponse() on the FacesContext.

The updated values of the Map strings in the params object are correct when
displayed with a outputText component. But when used with an inputText
component the value isn't updated.

I found these threads which seem to be about this issue, but they don't seem
to provide a solution :
http://www.mail-archive.com/users@myfaces.apache.org/msg12368.html
http://forum.java.sun.com/thread.jspa?threadID=720889&start=0&tstart=0

Any help is greatly appreciated.

Cheers,
 Mikael

Re: Advice please, updated model via valueChange event not render the way I thought

Posted by Mikael Andersson <ma...@gmail.com>.
Thanks,
that's great will give that try that now.

Grazie,
 Mikael

On 05/04/06, Mario Ivankovits <ma...@ops.co.at> wrote:
>
> Hi!
> > The updated values of the Map strings in the params object are correct
> > when displayed with a outputText component. But when used with an
> > inputText component the value isn't updated.
> You'll find a valueChangeNotifier in tomahawk sandbox which will fix
> your problem.
>
> A jsp example:
>       <h:selectOneMenu value="#{notifierBean.selectedCategory}"
> onchange="submit()">
>
>           <s:valueChangeNotifier method="#{notifierBean.valueChange}" />
>           <f:selectItems value="#{notifierBean.categories}" />
>
>       </h:selectOneMenu>
>
> In contrast to the valueChangeListener the valueChangeNotifier will be
> called later so that you can change your model values.
>
> Ciao,
> Mario
>
>

Re: Advice please, updated model via valueChange event not render the way I thought

Posted by Anthony Hong <an...@gmail.com>.
Can you give me Facelet tag.xml for this component?

On 4/6/06, Mike Kienenberger <mk...@gmail.com> wrote:
> On 4/5/06, Mikael Andersson <ma...@gmail.com> wrote:
> > you don't happen to know how to get the valueChangeNotifier to work with
> > facelets do you?
> >
> > I downloaded the sandbox.taglib.xml from the facelet website but it didn't
> > contain an entry for that tag, and I am not quite sure of how to add it
> > myself since it isn't an ordinary component.
>
> Yes, this component isn't alternate-viewhandler friendly.   There's
> component logic in the JSP tag file.
>
> I solved this problem by using the optional validation framework.
> You'd probably be better off giving the sandbox subforms a shot
> instead.
>
> Basically you want your pulldown to be in a logical "form" by itself
> so it passes validation and registers its model value despite whatever
> else is on the page.
>


--

Anthony Hong

Re: Advice please, updated model via valueChange event not render the way I thought

Posted by Mike Kienenberger <mk...@gmail.com>.
On 4/5/06, Mikael Andersson <ma...@gmail.com> wrote:
> you don't happen to know how to get the valueChangeNotifier to work with
> facelets do you?
>
> I downloaded the sandbox.taglib.xml from the facelet website but it didn't
> contain an entry for that tag, and I am not quite sure of how to add it
> myself since it isn't an ordinary component.

Yes, this component isn't alternate-viewhandler friendly.   There's
component logic in the JSP tag file.

I solved this problem by using the optional validation framework.  
You'd probably be better off giving the sandbox subforms a shot
instead.

Basically you want your pulldown to be in a logical "form" by itself
so it passes validation and registers its model value despite whatever
else is on the page.

Re: Advice please, updated model via valueChange event not render the way I thought

Posted by Mikael Andersson <ma...@gmail.com>.
Hi again,
you don't happen to know how to get the valueChangeNotifier to work with
facelets do you?

I downloaded the sandbox.taglib.xml from the facelet website but it didn't
contain an entry for that tag, and I am not quite sure of how to add it
myself since it isn't an ordinary component.

(I know I should use the facelets users mailing list for this but thought
I'd try here first since I got the thread going).

Cheers,
Micke

On 05/04/06, Mario Ivankovits <ma...@ops.co.at> wrote:
>
> Hi!
> > The updated values of the Map strings in the params object are correct
> > when displayed with a outputText component. But when used with an
> > inputText component the value isn't updated.
> You'll find a valueChangeNotifier in tomahawk sandbox which will fix
> your problem.
>
> A jsp example:
>       <h:selectOneMenu value="#{notifierBean.selectedCategory}"
> onchange="submit()">
>
>           <s:valueChangeNotifier method="#{notifierBean.valueChange}" />
>           <f:selectItems value="#{notifierBean.categories}" />
>
>       </h:selectOneMenu>
>
> In contrast to the valueChangeListener the valueChangeNotifier will be
> called later so that you can change your model values.
>
> Ciao,
> Mario
>
>

Re: Advice please, updated model via valueChange event not render the way I thought

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> The updated values of the Map strings in the params object are correct
> when displayed with a outputText component. But when used with an
> inputText component the value isn't updated.
You'll find a valueChangeNotifier in tomahawk sandbox which will fix
your problem.

A jsp example:
      <h:selectOneMenu value="#{notifierBean.selectedCategory}"
onchange="submit()">
     
          <s:valueChangeNotifier method="#{notifierBean.valueChange}" />
          <f:selectItems value="#{notifierBean.categories}" />
     
      </h:selectOneMenu>   

In contrast to the valueChangeListener the valueChangeNotifier will be
called later so that you can change your model values.

Ciao,
Mario