Yes, but the ValueChangeEvent will be processed in the Process
Validations phase, after submitting the form. So if you want to change
the value of the other inputText when the first changes, you need to
submit the form (technique #1). Otherwise, you can use javascript if
it is an option to you (if you don't have to process the form).
Hope it is clear now,
Bruno
2005/10/25, Jeffrey Porter <[EMAIL PROTECTED]>:
>
> Thanks Bruno. Great links.
>
>
> The spec for h:inputText states that it has the MethodBinding attribute
> valueChangeListener.
>
> So if I set this as...
>
> <h:inputText id="name" value="#{ncm.name}" required="true"
> valueChangeListener="#{ncm.changeEvent}" />
>
> Should it not call my method in the ncm class?
>
> public void changeEvent(ValueChangeEvent event) {
> String partNo = ((String)event.getNewValue());
> }
>
> Or am I missing something?
>
> Jeff.
>
>
>
> -----Original Message-----
> From: Bruno Aranda [mailto:[EMAIL PROTECTED]
> Sent: 25 October 2005 11:34
> To: MyFaces Discussion
> Subject: Re: valueChangeListener - inputText - Which method is correct?
>
> If it applies, you can use the technique explained in
> http://wiki.apache.org/myfaces/SubmitPageOnValueChange using the
> inputText instead of the selectOneMenu. It should work.
> Or if you want to play with javascript you can take a look at
> http://www.irian.at/myfaces/jslistener.jsf to see how the jslistener
> works,
>
> Regards,
>
> Bruno
>
> 2005/10/25, Jeffrey Porter <[EMAIL PROTECTED]>:
> >
> >
> >
> > I've seen 3 different examples of using the "valueChangeListener"
> attribute.
> >
> >
> >
> > I've seen...
> >
> >
> >
> > Example 1:
> >
> >
> >
> > JSP <h:inputText value="foo">
> > <f:valueChangeListener type="com.jsf.MyValueChangeListener"/>
> > </h:inputText>
> >
> >
> >
> >
> > CODE public class MyValueChangeListener implements ValueChangeListener
> {
> > public MyValueChangeListener() { }
> >
> > public void processValueChange(ValueChangeEvent vce)
> > throws AbortProcessingException {
> > System.out.println("A value has changed!");
> > }
> > }
> >
> >
> >
> >
> > Example 2:
> >
> >
> >
> > JSP
> >
> > <h:inputText id="partNumber"
> > value="#{nonConformingMaterial.partNumber}" required="true"
> >
> > valueChangeListener="#{nonConformingMaterial.changeEvent}"
> >
> > onclick="submit()"
> >
> > immediate="true"
> >
> > />
> >
> >
> >
> > Example 3:
> >
> >
> >
> > JSP <s:inputSuggestAjax
> suggestedItemsMethod="#{inputSuggestAjax.getItems}"
> > styleLocation="" />
> >
> >
> >
> >
> >
> >
> >
> >
> > I like example 3, very sexy. (see
> > http://irian.at/myfaces-sandbox/inputSuggestAjax.jsf)
> >
> > But it's not what I need in my application.
> >
> >
> >
> > What I need is, when an inputText is filled in, an action is called so
> that
> > another inputText field is automatically filled in.
> >
> >
> >
> > I presume that I should be trying to get example 1 working. Would you
> agree?
> >
> >
>