JSF标签详解
来源:互联网 发布:淘宝怎么优化宝贝 编辑:程序博客网 时间:2024/05/17 01:33
了解更多详细内容:http://www.tutorialspoint.com/jsf/index.htm
HTML标记库
HTML输入标记
inputHidden
隐藏输入框,即输出<input>
HTML标签,其type属性设定为hidden,隐藏输入框的值用于保留一些信息于客户端,以在下一次发送表单时一并提交,例如:
<h:inputHidden value="#{user.hiddenInfo}"/>
inputSecret
显示密码输入框,即输出<input>
HTML标签,其type属性设定为password,
例如:
<h:inputSecret value="#{user.password}"/>
您可以设定redisplay属性以决定是否要显示密码栏目的值,预设是false。
inputText
显示单行输入框,即输出<input>
HTML标签,其type属性设定为text。
例如:
<h:inputText value="#{user.name}"/>
inputTextarea
显示多行输入文字区域,即输出<textarea>
HTML标签,例如:
<h:inputTextarea value="#{user.command}"/>
HTML输出标记
outputFormat
产生指定的文字信息,可以搭配<f:param>
来设定信息的参数以格式化文字信息,
例如:
<f:loadBundle basename="messages" var="msgs"/><h:outputFormat value="#{msgs.welcomeText}"><f:param value="Hello"/><f:param value="Guest"/></h:outputFormat>
outputLabel
产生<label>
HTML标签,使用for属性指定组件的client ID,例如:
<h:inputText id="user" value="#{user.name}"/><h:outputLabel for="user" value="#{user.name}"/>
这会产生像是以下的标签:
<input id="user" type="text" name="user" value="guest" /><label for="user">
outputLink
产生<a>
HTML标签,例如:
<h:outputLink value="../index.jsp"><h:outputText value="Link to Index"/><f:param name="name" value="MyName"/></h:outputLink>
你可搭配<f:param>
帮链结加上参数,所有的参数都会变成 name=value 的类型附加在链接后。
value所指定的内容也可以是JSF EL绑定。
outputText
简单的显示指定的值或绑定的信息,例如:
<h:outputText value="#{user.name}"/>
graphicImage
<h:graphicImage>
标签会绘制一个HTML <img>
标签,value可以指定路径或图片URL,路径可以指定相对路径或绝对路径,例如
>`
<h:graphicImage value="/images/logowiki.jpg"/
HTML命令标记
commandButton
显示一个命令按钮,即输出<input>
HTML标签,其type属性可以设定为button、submit或reset,预设是submit,按下按钮会触发 javax.faces.event. ActionEvent,使用例子如下:
<h:commandButton value="提交" action="#{user.verify}"/>
commandLink
产生超链接,会输出<a>
HTML标签,而href属性会有’#’。
示范代码:
<h:commandLink value="#{msgs.commandText}"action="#{user.verify}"/>
HTML选择标记
selectOneListbox
单选列表框。
使用示范代码:
<h:selectOneListbox layout="pageDirection" value="#{user.education}"> <f:selectItem itemLabel="高中" itemValue="高中"/> <f:selectItem itemLabel="大學" itemValue="大學"/> <f:selectItem itemLabel="研究所以上" itemValue="研究所以上"/></h:selectOneListbox>
selectOneMenu
下拉框,,和HTML的下拉框一样。
使用示范代码:
<h:selectOneMenu layout="pageDirection" value="#{user.education}"> <f:selectItem itemLabel="高中" itemValue="高中"/> <f:selectItem itemLabel="大學" itemValue="大學"/> <f:selectItem itemLabel="研究所以上" itemValue="研究所以上"/></h:selectOneMenu>
selectOneRadio
单选按钮集,类似网页的<input type="radio" ....
使用示例如下:
<h:selectOneRadio value="#{user.education}"> <f:selectItem itemLabel="高中" itemValue="高中"/> <f:selectItem itemLabel="大学" itemValue="大学"/> <f:selectItem itemLabel="研究所以上" itemValue="研究所以上"/></h:selectOneRadio>
selectBooleanCheckbox
在视图上呈现一个复选框。
例如:
我同意 <h:selectBooleanCheckbox value="#\{user.aggree\}"/>
value所绑定的属性必须接受与传回boolean类型
selectManyCheckbox
这个标签提供使用者复选项目的功能
例子如下:
<h:selectManyCheckbox layout="pageDirection" value="#{user.preferColors}"> <f:selectItem itemLabel="红" itemValue="false"/> <f:selectItem itemLabel="黄" itemValue="false"/> <f:selectItem itemLabel="蓝" itemValue="false"/></h:selectManyCheckbox>
selectManyListbox
这个标签提供使用者复选项目的功能
<h:selectManyListbox layout="pageDirection" value="#{user.preferColors}"> <f:selectItem itemLabel="红" itemValue="false"/> <f:selectItem itemLabel="黄" itemValue="false"/> <f:selectItem itemLabel="蓝" itemValue="false"/></h:selectManyListbox>’
electManyMenu
这个标签提供使用者复选项目的功能。
例子如下:
<h:selectManyMenu layout="pageDirection" value="#{user.preferColors}"> <f:selectItem itemLabel="红" itemValue="false"/> <f:selectItem itemLabel="黄" itemValue="false"/> <f:selectItem itemLabel="蓝" itemValue="false"/></h:selectManyMenu>
HTML消息标记
message
显示一个组件的最近使用的消息,
示范代码:
<h:inputText id="inp2" /><h:message for="inp2" showSummary="false" showDetail="true" />
messages
h:messages用于显示所有消息。
使用示范代码:
<h:messages id="messageAll" showDetail="true" showSummary="true"/>
HTML布局标记
panelGrid
这个标签可以用来作简单的组件排版,它会使用HTML表格标签来绘制表格,并将组件置于其中,主要指定columns属性。
例如:
<h:panelGrid columns="2"><h:outputText value="Username"/><h:inputText id="name" value="#{userBean.name}"/>。。。。</h:panelGrid>
panelGroup
这个组件用来将数个JSF组件包装起来,使其看来像是一个组件,例如:
<h:panelGroup><h:commandButton value="submit" action="login"/><h:commandButton value="reset" type="reset"/></h:panelGroup>
HTML数据表标记
dataTable
很多数据经常使用表格来表现,JSF提供<h:dataTable>
标签让您得以列举数据并使用表格方式来呈现。
示范代码:
<h:dataTable value="#{tableBean.userList}" var="user"> <h:column> <h:outputText value="#{user.name}"/> </h:column> <h:column> <h:outputText value="#{user.password}"/> </h:column> </h:dataTable>
column
<h:dataTable>
配合<h:column>
来以表格的方式显示数据,< h:column>
中只能包括 JSF组件或者是<f:facet>
,JSF支援两种facet:header与footer。
示范代码:
<h:dataTable value="#{tableBean.userList}" var="user"> <h:column> <f:facet name="header"> <h:outputText value="Name"/> </f:facet> </h:column></h:dataTable>
核心标记库
验证器标记
validateDoubleRange
用于验证用户在UI组件中输入的双精度型范围的值的个数
f:validateDoubleRange可以对所有输入类型的组件的输入值加以验证。
f:validateDoubleRange必须被包含在上述输入组件之内。例:
<h:inputText id="amount" value="#{mybean.amount}" required="true"> <f:validateDoubleRange maximum="2500.8" minimum="0.00"></f:validator> </h:inputText>
validateLength
用于验证用户在UI组件中输入的字符数
示范代码:
<h:inputText id="userId" value="#{mybean.userId}" required="true"> <f:validateLength maximum="16" minimum="8" /> </h:inputText>
validateLongRange
用于验证用户在UI组件中输入的长整型范围的值的个数
f:validateLongRange可以对所有输入类型的组件的输入值加以验证。
f:validateLongRange必须被包含在上述输入组件之内
<h:inputText id="amount" value="#{mybean.amount}" required="true"> <f:validateLongRange maximum="2500" minimum="800" /> </h:inputText>
validate
用于根据应用程序的需要在给定的UI组件上执行自定义验证
转换器标记
convertDateTime
该组件用于向父组件添加DateTime转换器实例
f:convertDateTime标签用来转换日期格式。
示范代码:
<h:outputText value="#{bean.outputDate}"> <f:convertDateTime pattern="yyyy年MM月dd日"/></h:outputText>
converter
该组件用于向父组件添加任意转换器实例
JSF可以使用 f:converter简单地调用指定converter-id的JSF Converter实现(实现javax.faces.convert.Converter接口的类)对JSF组件组件的输入输出值加以变换。
示范代码:
<h:inputText value="123456"> <f:converter converterId="myConverterId" /> </h:inputText>
convertNumber
该组件用于向父组件添加Number转换器实例
f:convertNumber用来对数字,通货等等进行格式转换
示范代码:
<h:inputText value="123456"> <f:convertNumber type="currency" currencySymbol="$"/> </h:inputText>
事件侦听标记
actionListener
该组件用于向父组件添加操作侦听器实例
f:actionListener标签为h:commandLink,h:commandButton等指定自定义的事件侦听类。
f:actionListener使用:
JSP:
<h:commandButton id="regist" value="Regist"> <f:actionListener type="mypackage.ActionListenerImpl"></f:actionListener> </h:commandButton>
valueChangeListener
valueChangeListener用于向父组件添加值变更监听器。
示范代码:
<h:selectBooleanCheckbox id="sbc_operate" value="#{pc_Attribute.selected}" valueChangeListener="#{pc_Attribute.onOperateSelectedChange}" onclick="submit();">
setPropertyActionListener
该`组件用于注册特殊操作侦听器实例,
它的目的是在提交表单时,向bean注入一个值。
视图标记
view
- 用于将所有UI组件组合在一起,这些组件一起形成了容器内JSF页面的视图
- 通过表示
-创建JSF页面的顶层视图并充当所有作为JSF页面一部分的UI组件的容器,例如:JSF HTML 标记 和 JSF 核心标记 - 使用标记可:
在给定的JSF视图内创建子视图
表示在另一个JSF页面中定义的一部分显示
使用样例:
<html><body> <f:view> <h:column> <h:outputText value="#{user.name}"/> </h:column> </f:view></body></html>
选择标记
selectItem
f:selectItem 指定 UISelectOne 或 UISelectMany 组件的一个项目,用来为h:selectOneMenu等选择性组件设置选择数据项。
示范代码:
<h:selectOneMenu value="#{bean.selectedItemValue}"> <f:selectItem itemLabel="Label1" value="0" /> <f:selectItem itemLabel="Label2" value="1" /></h:selectOneMenu>
selectItems
f:selectItems用于指定 UISelectOne 或 UISelectMany 组件的多个项目,
与f:selectItem标签一样,用来为
- h:selectManyCheckbox
- h:selectManyListbox
- h:selectManyMenu
- h:selectOneListbox
- h:selectOneMenu
- h:selectOneRadio
等设置数据项。
Facet标记
facet
f:facet标签用来为包含f:facet标签的父组件与被f:facet标签所包含的子组件之间申明一种特殊的关系。常与h:panelGrid,h:dataTable等标签连用,申明组件为标题或页脚。
示范代码:
<f:facet name="header"> <h:outputText value="Title"/> </f:facet>
attribute
f:attribute标签用来设置父标签的属性。
f:attribute标签使用例:
JSP:
<h:graphicImage url="/images/picture.jpg"> <f:attribute name="height" value="20"/> <f:attribute name="width" value="10"/> </h:graphicImage>
loadBundle
f:loadBundle是JSF提供的一个支持JSP本地化(多语言支持)操作的标签。
示范代码:
<f:loadBundle basename="com.test.resource.Messages" var="msg" />
param
f:param 用于向组件添加参数。一般用法主要有2种:
<h:outputLink value="/someUrl"> <f:param name="id" value="#{bean.id}"/> <f:param name="name" value="#{bean.name}"/></h:outputLink>或<h:outputFormat value="You have {0} items in your shopping cart."> <f:param value="#{SessionBean1.cart.itemCount}"/> </h:outputFormat>
subview
可以使用f:subview包含指定的JSF页面,或者其他JSF组件。
使用f:subview包含JSF页面时,被包含的页面里只能包含有JSF组件,所有非JSF组件元素必须用f:verbatim标签进行转换。
示范代码:
<f:subview id="id3"> <%@ include file="subpage.jsp" %> </f:subview>
verbatim
简单说来就是,标签里包含什么,就在网页上输出什么。
示范代码:
<f:verbatim><li /></f:verbatim>
- JSF标签详解
- jsf标签详解
- Jsf标签详解(全)
- [JSF]JSF标签
- JSF标签
- JSF标签
- jsf标签
- JSF——JSF 标签
- JSF详解
- JSF html标签
- JSF标签属性
- jsf 标签介绍1
- JSF组件标签
- jsf的标签
- JSF标签-loadBundle
- JSF 标签h:panelGrid
- jsf常用的标签
- JSF标签学习
- IM接入启动问题
- 成长的速度:最好符合自然增长率
- Struts2_token原理
- 苹果官方教材:如何使用 Boot Camp 来安装 Windows
- It is indirectly referenced from required .class file
- JSF标签详解
- Linux_系统状态检测及进程控制
- 注意数据库字段类型
- Linux_tail
- Yii框架自定义默认控制器和方法
- Eclipse: The declared package does not match the expected package
- Linux_reboot tomcat
- 无分类域间路由选择相关计算题
- Scrapy学习笔记V--Items 爬虫数据的存储.数据模板