JSF组件绑定 - 有些混乱 [英] JSF component binding - some confusion

查看:204
本文介绍了JSF组件绑定 - 有些混乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从这样的网页之一,

<一个href=\"http://www.jsftutorials.net/components/step5.html\">http://www.jsftutorials.net/components/step5.html

据我了解,在JSF标签/视图组件绑定属性是视图组件绑定到后端bean中UI组件的Java实例。

I understand that the binding attribute in JSF tag/view component is to bind the view component to a Java instance of the UI component in the backing bean.

例如,这就是在以下code完成的:

E.g., that's what is done in the following code:

<h:inputText value="#{ myBean.someProperty}" binding="#{ myBean.somePropertyInputText}"/>

但有时我看到<一个href=\"http://illegalargumentexception.blogspot.com/2009/10/jsf-working-with-component-identifiers.html#componentbindingclientid\">$c$c这样:

<h:commandButton id="t1" binding="#{foo}" value="Hello, World!" onclick="alert('I am #{id:cid(foo)}'); return false;" />

其中, ID:CID 是被定义为如下标签库函数:

where id:cid is a taglib function which is defined as follow:

public static String cid(UIComponent component) {
    FacesContext context = FacesContext.getCurrentInstance();
    return component.getClientId(context);
}

在上面的code,绑定=#{富}不结合的支持bean的UI组件的Java实例。

In the above code, binding="#{foo}" does not bind to "a Java instance of the UI component in the backing bean".

那么,什么是前pressions如绑定=#{}富

So what is the meaning of expressions such as binding="#{foo}" ?

推荐答案

它只是绑定组件到当前的facelet范围。如果你不需要它在辅助bean在所有这是特别有用。这从中没有得到任何其他方法都用无用的属性可以节省您的支持bean code。请注意,它也可以在JSF 1.2的方式。不知道JSF 1.0 / 1.1,虽然,因为它使用了不同的和JSF-EL专利API。

It just binds the component to the current Facelet scope. This is particularly useful if you don't need it in the backing bean at all. This saves your backing bean code from useless properties which aren't been used in any of the other methods at all. Note that it also works that way in JSF 1.2. Not sure about JSF 1.0/1.1 though as it uses a different and JSF-proprietary EL API.

  • JSF component binding without bean property

这篇关于JSF组件绑定 - 有些混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆