关于JSF的binding

来源:互联网 发布:淘宝填写退货物流信息 编辑:程序博客网 时间:2024/06/13 23:48

 今天看了一下JSF的一些帮助文档,但是对binding的使用说明实在有点简单,也没有举例说明,搞得有点模模糊糊的,很是不明白。于是在网上看了一下网友们的blog,大概是明白了binding的用法。举例如下:

public class userBean{

    private UIInput textInput=null;

public void setTextInput(UIInput ti){

    this.textInput=ti;

}

public UIInput getTextInput()

{
return textInput;

}

public String clickButton(){

textInput.setValue("hello world");

return null;

}

}

-----------------------------------------------------

<h:inputText value="" binding="#{userBean.textInput}/>

<h:command action="#{userBean.clickButton}" value="click"/>

当button被点去后就能立即更新inputText的值,在这里有点像reRender的功能,但用binding你可以在javaBean中方便的操作被绑定的component的textInput的其它选项。

这里只是个人的一点看法,可能有误,欢迎大家指正。

原创粉丝点击