jsf in action 笔记:理解组件和客户端的标识(Understanding component and client identifiers)--2008.04.09
2008-04-09 10:21
591 查看
摘自 JSF in action 2.3 Understanding component and client identifiers 页面:Page/103
1. UI component 生活在两个分开的世界,服务器端和客户端.在服务器端以java对象的形式存在(猜想应该是一个UIViewRoot对象),表达的是一个组件树.在客户端通常以标记语言的形式存在(例如Html).
2. 组件在服务器端有一个组件标识(component identifier),可以通过这个标识找到这个组件对象,在客户端,每个组件可以通过客户端标识(client identifier)来得到组件,客户端的标识起源于服务器端的组件标识.在客户端,通过javascript,css等语言取得客户端标识对组件进行控制.
3. 客户端的标识为服务器端和客户端架起了一座桥梁,当用户在客户端进行提交时,客户端的这些标识会随request一起传递到服务器端,服务器端根据这些标识(也就是参数的名称)对服务器端的组件进行赋值.
4.以下为组件的示例图
Figure 2.6 Components instances on the server are referenced via component identifiers. On the client, they are referenced by client identifiers. Sometimes the two are the same.
5. 以下为服务器端的代码:
<p>
<h:outputText id="outputText" value="What are you looking at?"/>
</p>
<h:form id="myForm">
<p>
<h:inputText/>
</p>
<p>
<h:inputText id="inputText"/>
</p>
...
</h:form>
客户端的显示为:
<p>
<span id="outputText">What are you looking at?</span>
</p>
<form id="myForm" method="post"
action="/jia-standard-components/client_ids.jsf"
enctype="application/x-www-form-urlencoded">
<p>
<input type="text" name="myForm:_id1" />
</p>
<p>
<input id="myForm:inputText" type="text" name="myForm:inputText" />
</p>
...
</form>
6. 可以看出如果在组件中不设定id那么JSF会自动设定这个id,组件标识和客户端标识中间存在着对应关系,有时两个的值是一样的,组件的标识名称要符合一定的规范,只能以字母或下划线开头,后面跟字母,数字,中划线和下划线(Component identifiers must start with a letter or an underscore (_) and be composed of letters, numbers, dashes (-) and underscores),而且长度尽量要短,以避免提交回复时的字节长度.如果组件不被java程序或客户端来引用,那么可以不用设定标识.
1. UI component 生活在两个分开的世界,服务器端和客户端.在服务器端以java对象的形式存在(猜想应该是一个UIViewRoot对象),表达的是一个组件树.在客户端通常以标记语言的形式存在(例如Html).
2. 组件在服务器端有一个组件标识(component identifier),可以通过这个标识找到这个组件对象,在客户端,每个组件可以通过客户端标识(client identifier)来得到组件,客户端的标识起源于服务器端的组件标识.在客户端,通过javascript,css等语言取得客户端标识对组件进行控制.
3. 客户端的标识为服务器端和客户端架起了一座桥梁,当用户在客户端进行提交时,客户端的这些标识会随request一起传递到服务器端,服务器端根据这些标识(也就是参数的名称)对服务器端的组件进行赋值.
4.以下为组件的示例图
Figure 2.6 Components instances on the server are referenced via component identifiers. On the client, they are referenced by client identifiers. Sometimes the two are the same.
5. 以下为服务器端的代码:
<p>
<h:outputText id="outputText" value="What are you looking at?"/>
</p>
<h:form id="myForm">
<p>
<h:inputText/>
</p>
<p>
<h:inputText id="inputText"/>
</p>
...
</h:form>
客户端的显示为:
<p>
<span id="outputText">What are you looking at?</span>
</p>
<form id="myForm" method="post"
action="/jia-standard-components/client_ids.jsf"
enctype="application/x-www-form-urlencoded">
<p>
<input type="text" name="myForm:_id1" />
</p>
<p>
<input id="myForm:inputText" type="text" name="myForm:inputText" />
</p>
...
</form>
6. 可以看出如果在组件中不设定id那么JSF会自动设定这个id,组件标识和客户端标识中间存在着对应关系,有时两个的值是一样的,组件的标识名称要符合一定的规范,只能以字母或下划线开头,后面跟字母,数字,中划线和下划线(Component identifiers must start with a letter or an underscore (_) and be composed of letters, numbers, dashes (-) and underscores),而且长度尽量要短,以避免提交回复时的字节长度.如果组件不被java程序或客户端来引用,那么可以不用设定标识.
相关文章推荐
- jsf in action 笔记:在组件中使用EL语言(Using the EL with components)--2008.04.11
- jsf in action 笔记:命名容器(Naming container)--2008.04.09
- jsf in action 笔记:bean的创建和初始化(一)(3.3 Creating and initializing beans)--2008.04.12
- jsf in action 笔记:标准组件(一)--组件列表--2008.04.16
- jsf in action 笔记:页面语言(Expression Language)--2008.04.09
- jsf in action 笔记:web.xml配置(Configuration)--2008.04.11
- jsf in action 笔记:通过值绑定初始化Bean(Setting values with value-binding expressions)--2008.04.15
- Vue2学习笔记:组件(Component)
- [源码学习] -- yii2源码学习笔记(四) -- 继续了解组件Component.php
- JSF in action笔记--术语(jsf pie)--2008.04.07
- Visualizing and Understanding Convolutional Networks 阅读笔记-网络可视化NO.1
- [深度学习]Visualizing and Understanding Convolutional Networks阅读笔记
- AngularJs学习笔记--Understanding the Controller Component
- Understanding JOINs in MySQL and Other Relational Databases 理解JOIN在MySQL和其他数据库中的运用
- JSF自定义组件之四 JSF实现-Component
- <React: Up and Running>阅读笔记 — The life of a component & Excel: a fancy table component
- React学习笔记_无状态组件(Stateless Component) 与高阶组件
- vue2.0-组件-文档理解笔记v1.0
- Visualizing and Understanding Convolutional Networks笔记1
- AngularJs学习笔记--Understanding the Model Component