views:

1112

answers:

1

I have such code

<a4j:region>
 <h:inputText label="User" id="user"  size="30" value="#{bean2.val1}" required="true" >
    <a4j:support event="onblur" action="#{bean.action}" reRender="outputName" bypassUpdates="true">
       <a4j:actionparam name="user" assignTo="#{bean.user}" value="#{user}"  />
    </a4j:support>
 </h:inputText>    
</a4j:region>
<h:message for="user"/>

And my bean class like this :

  private String user;
  public String getUser() {
        System.out.println("user=="+user);
    return user;
  }
  public void setUser(String user) {
      this.user = user;
  }
  public void action(){
      getUser();
  } 

But every time onblur event occurs, the value of user alway null.

I just want to the value of user send to the bean when onblur event occur. So I can get value of user. Anyone can help me ? (I'm sorry for my English)

A: 

Well, the value of #{user} is null always - there is no such thing in the request attributes. You can remove the <a4j:actionparam whatsoever and just leave the <a4j:support, and preferably put ajaxSignle=true. This will first submit the value of the text input and then execute the action (at least it should). Also put immediate=true to bypass validation.

After you comment, I think you could also try:

<a4j:actionparam name="user" assignTo="#{bean.user}" value="#{bean2.val1}"  />

Or do the assignment in the action method manually. Just inject the second bean into the first one (assuming you use a DI framework)

Bozho
Thanks Bozho.I've try that n get value of bean.user [email protected] my point, inputText value is bean2.val. Onblur action to bean.action. And i want to take input value from that action or from bean.user, is that possible? (2 different beans there)