f:facet

《Java Server Faces 2.0,The Complete Reference》对f:facet是这样解释的:

 

The f:facet tag signifies a nested component that has a special relationship to its enclosing

tag. For example, stating that the “header” of a table is to be provided by a JSF component.

This element adds the component represented by the JSF action in its body as a facet with

the specified name to the component represented by the closest JSF component parent

action element. This tag only allows one component to be nested within itself. To use

multiple components as a facet, create them as children of a simple container component.

For example, nest the corresponding HTML library component actions within the body of

a panelGroup component.

意思是:f:facet表示一个"被嵌套组件",这个组件和包含它的标签有特定关系的。...(<f:facet>被嵌套组件</f:facet>,一次只能包含一个"被嵌套组件")

 

 

JSFToolBox网站上是这样解释的:

 

The Facet tag registers a named facet on the component associated with the enclosing tag. A facet represents a named section within a container component. For example, you can create a header and a footer facet for a dataTable component.

意思和上面差不多。

 

 

能找到的资料上基本都是举这样一个例子来试图说明f:facet的用法:

 

疑问来了,既然name="****"代表的是facet与包含它的组件的关系,那么这个关系是不是可以自己随便写呢?"被嵌套组件"是不是可以随便写呢?

改写上面的代码:

 

运行发现header变成了不再是文字,而是一个输入框,

<f:facet name="relation"> <h:outputText value="Daily Report" /> </f:facet>没有任何输出。

 

结论:

The name attribute sets the name of the facet to be created. Some components have facets with predefined names, such as the "header" and "footer" facets of the component associated with the h:dataTable tag.

 

只有组件预先就定义好的name的facet才能被接受,比如h:dataTable就预先定义了名为"header"和"footer"的facet。<f:facet>标签对之间的内容可以是任意组件。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值