Ajax Primefaces在managedBean中获取inputText值

Ajax Primefaces在managedBean中获取inputText值,ajax,primefaces,Ajax,Primefaces,我的问题对于熟悉Primefaces的人来说应该是微不足道的,但我才刚刚开始。我的问题是: 当我将inputText组件放入我的网页时,如下所示: <h:form id="formularz"> <p:inputText id="workyears" value="#{appointentBean.year}" style="width: 40px;"/> <h:form> 您可以使用类似以下()的事件来完成此操作: PS:欢迎来到Primeface

我的问题对于熟悉Primefaces的人来说应该是微不足道的,但我才刚刚开始。我的问题是: 当我将inputText组件放入我的网页时,如下所示:

<h:form id="formularz">
    <p:inputText id="workyears" value="#{appointentBean.year}" style="width: 40px;"/>
<h:form>

您可以使用类似以下()的事件来完成此操作:


PS:欢迎来到Primefaces

通过
my field year in AppointBean自动更新,同时有人将文本放入inputText组件中
您的意思是与按键事件进行ajax交互以调用您的方法?是否要直接检索输入的文本
-->
这是您所说的自动完成吗?。自动更新?是的,我将使用commandButton调用我的方法
@ManagedBean
@ViewScoped
@SessionScoped
public class appointentBean{

    private int year;

public int getYear() {
    return year;
}

public void setYear(int year) {
    this.year = year;
}

    //Here I will put another method that will be operate on year value
}
<h:form>
    <p:inputText value="#{viewMBean.hello}">
        <p:ajax event="keyup" update="hello" process="@this" />  
    </p:inputText>

    <h:outputText id="hello" value="#{viewMBean.hello}" />
</h:form>
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

@ManagedBean
@ViewScoped
public class ViewMBean implements Serializable {

    private String hello;

    public String getHello() {
        return hello;
    }

    public void setHello(String hello) {
        this.hello = hello;
    }

}