2

I have <h:inputText> on form and what I need is to execute some method from backing bean on BLUR event:

public void test()  
{  
  System.out.print("HELLO!");  
}  

Can you help me?

niksvp
  • 5,545
  • 2
  • 24
  • 41
gaffcz
  • 3,469
  • 14
  • 68
  • 108

1 Answers1

8

You can use <f:ajax>

<h:form>           
      <h:inputText value="#{managedBean.val}" > 
        <f:ajax event="blur" render="result" listener="#{managedBean.test}"/> 
      </h:inputText>           
</h:form>

@ManagedBean(name = "managedBean") 
public class Bean { 
   private String val; // getter and setter 

   ... 

   public void test() {  
      System.out.print("HELLO!");  
   }  

}

Alternative :

If you are using richfaces then you can use a4j:jsFunction


See Also

Community
  • 1
  • 1
jmj
  • 237,923
  • 42
  • 401
  • 438
  • Thank you, Jigar. But are you sure that listener is working? It writes HELLO to console only after refresh of page... – gaffcz May 31 '11 at 07:11
  • Yes it will work. may be you can change the event to onkeyup to debug – jmj May 31 '11 at 07:12