You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Jeffrey Porter <PO...@WMGMAIL.wmg.warwick.ac.uk> on 2005/10/25 12:02:18 UTC

valueChangeListener - inputText - Which method is correct?

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? 

 


Re: valueChangeListener - inputText - Which method is correct?

Posted by Bruno Aranda <br...@gmail.com>.
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 <PO...@wmgmail.wmg.warwick.ac.uk>:
>
>
>
> 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?
>
>