jsf in action 笔记:命名容器(Naming container)--2008.04.09

本文介绍了JSF中命名容器的概念及其重要性。UIViewRoot虽然不是命名容器,但也要求其子组件标识唯一。HtmlForm和HtmlDataTable等是典型的命名容器。文章还解释了客户端标识的生成规则,并通过实例展示了即使组件标识相同,客户端标识也能保持唯一。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

摘录自JSF in action 2.3.1 Naming containers   Page/106

1.  A naming container is a component whose children all have unique component identifiers.--组件中所包含的子组件的标识不能有重复.尽管UIViewRoot不是命名容器,但是它也要求最高一级的组件中不能有相同的标识.(The view’s root node (UIViewRoot), which is the parent of all of the other components on a given page, is not a naming container, but it does require that top-level components in the same view must have different identifiers.)

2.  HtmlForm和HtmlDataTable都是Naming Container,一些第三方的组件也有可能是命名容器.

3.  客户端的标识(client identifier)在整个页面中都应该是唯一的(因为参数的名称必须是要唯一的)

JSF component and client identifier

4.以下为一个示例,两个组件的标识是相同的, 但是在客户端是不一样的

<f:view>
<h:form id="firstForm">
<h:inputText id="inputText"/>
...
</h:form>
<h:form id="secondForm">
<h:inputText id="inputText"/>
...
</h:form>
<f:view>

在客户端的展示为:

<form id="firstForm" method="post" action="/myapp/client_ids.jsf"
enctype
="application/x-www-form-urlencoded">
<input id="firstForm:inputText" type="text" name="firstForm:inputText"/>
...
</form>
<form id="secondForm" method="post" action="/myapp/client_ids.jsf">
<input id="secondForm:inputText" type="text" name="secondForm:inputText"/>
...
</form>

 

5.  客户端的标识生成是有规律的,由父标识和自身标识组成,中间默认为":"隔开,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值