在JSF中使用绑定属性有什么优势?

编程入门 行业动态 更新时间:2024-10-25 22:25:02
本文介绍了在JSF中使用绑定属性有什么优势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

请参见以下代码:

<h:inputText id="name" value="#{jsfBean.name}" binding="#{jsfBean.htmlInputText}"/>

在上面的示例中,我们使用绑定属性与服务器端bean属性进行链接.我想知道使用此属性和不使用此属性有什么区别.

In the above example we are using the binding attribute to link with the server side bean property. I want to know what is the difference in using this attribute and not using this attribute.

推荐答案

使用绑定属性,您将映射实际组件而不是组件的值.例如,示例的后备bean中的属性如下所示:

With binding attribute you are mapping the actual component and NOT the component's value. For e.g the property in backing bean for your sample looks like below

UIInput htmlInputText= null; ... public void setHtmlInputText(UIInput userNoComponent) { this.userNoComponent = userNoComponent; } public UIInput getHtmlInputText() { return userNoComponent; }

将组件实例绑定到Bean属性具有以下优点:

Binding a component instance to a bean property has these advantages:

  • 支持bean可以通过编程方式 修改组件属性.
  • 支持bean可以实例化 组件而不是让页面 作者这样做.
  • The backing bean can programmatically modify component attributes.
  • The backing bean can instantiate components rather than let the page author do so.

查找更多详细信息在本教程中

更多推荐

在JSF中使用绑定属性有什么优势?

本文发布于:2023-10-17 10:21:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1500633.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么   绑定   属性   优势   JSF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!