jsf标签

Jsf标签详解(一个不漏)
整理来自:www.web-tag.net


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>
更多 actionListener 信息
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>
更多 attribute 信息
convertDateTime

f:convertDateTime标签用来转换日期格式。
示范代码:
<h:outputText value="#{bean.outputDate}">
<f:convertDateTime
pattern="yyyy年MM月dd日"/>
</h:outputText>

更多 convertDateTime 信息
converter

JSF可以使用 f:converter简单地调用指定onverter-id的JSF Converter实现(实现javax.faces.convert.Converter接口的类)对JSF组件组件的输入输出值加以变换。
示范代码:
<h:inputText value="123456">
<f:converter converterId="myConverterId" />
</h:inputText>
更多 converter 信息
convertNumber

f:convertNumber用来对数字,通货等等进行格式转换
示范代码:
<h:inputText value="123456">
<f:convertNumber type="currency" currencySymbol="$"/>
</h:inputText>
facet

f:facet标签用来为包含f:facet标签的父组件与被f:facet标签所包含的子组件之间申明一种特殊的关系。常与h:panelGrid,h:dataTable等标签连用,申明组件为标题或页脚。
示范代码:
<f:facet name="header">
<h:outputText value="Title"/>
</f:facet>
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>
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
等设置数据项。
subview

可以使用f:subview包含指定的JSF页面,或者其他JSF组件。
使用f:subview包含JSF页面时,被包含的页面里只能包含有JSF组件,所有非JSF组件元素必须用f:verbatim标签进行转换。
示范代码:
<f:subview id="id3">
<%@ include file="subpage.jsp" %>
</f:subview>
validateDoubleRange

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

示范代码:
<h:inputText id="userId" value="#{mybean.userId}" required="true">
<f:validateLength maximum="16" minimum="8" />
</h:inputText>
validateLongRange

f:validateLongRange可以对所有输入类型的组件的输入值加以验证。
f:validateLongRange必须被包含在上述输入组件之内。例:
<h:inputText id="amount" value="#{mybean.amount}" required="true">
<f:validateLongRange maximum="2500" minimum="800" />
</h:inputText>
valueChangeListener

valueChangeListener 向父组件注册值变更监听器。
示范代码:
<h:selectBooleanCheckbox id="sbc_operate" value="#{pc_Attribute.selected}"
valueChangeListener="#{pc_Attribute.onOperateSelectedChange}"
οnclick="submit();">

verbatim

简单说来就是,标签里包含什么,就在网页上输出什么。
示范代码:
<f:verbatim><li /></f:verbatim>
view

view用于 创建顶层视图。
使用样例:
<html>
<body>
<f:view>
<h:column>
<h:outputText value="#{user.name}"/>
</h:column>
</f:view>
</body>
</html>
更多 view 信息
• JSF Form
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>
更多 column 信息
commandButton

commandButton
显示一个命令按钮,即输出<input> HTML标签,其type属性可以设定为button、submit或reset,预设是submit,按下按钮会触发 javax.faces.event. ActionEvent,使用例子如下:
<h:commandButton value="提交" action="#{user.verify}"/>
更多 commandButton 信息
commandLink

commandLink
产生超链接,会输出<a> HTML标签,而href属性会有'#'。
示范代码:
<h:commandLink value="#{msgs.commandText}"
action="#{user.verify}"/>
更多 commandLink 信息
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>
更多 dataTable 信息
form

<h:form>和HTML里面的form,用于表单数据提交。
更多 form 信息
graphicImage

<h:graphicImage>
这个标签会绘制一个HTML <img>标签,value可以指定路径或图片URL,路径可以指定相对路径或绝对路径,例如:
<h:graphicImage value="/images/logowiki.jpg"/>
更多 graphicImage 信息
inputHidden

inputHidden
隐藏输入框,即输出<input> HTML标签,其type属性设定为hidden,隐藏输入框的值用于保留一些信息于客户端,以在下一次发送表单时一并提交,例如:
<h:inputHidden value="#{user.hiddenInfo}"/>
更多 inputHidden 信息
inputSecret

inputSecret
显示密码输入框,即输出<input> HTML标签,其type属性设定为password,
例如:
<h:inputSecret value="#{user.password}"/>
您可以设定redisplay属性以决定是否要显示密码栏目的值,预设是false。
更多 inputSecret 信息
inputText

inputText显示单行输入框,即输出<input> HTML标签,其type属性设定为text。
例如:
<h:inputText value="#{user.name}"/>
更多 inputText 信息
inputTextarea

inputTextarea
显示多行输入文字区域,即输出<textarea> HTML标签,例如:
<h:inputTextarea value="#{user.command}"/>
更多 inputTextarea 信息
message

显示一个组件的最近使用的消息,
示范代码:
<h:inputText id="inp2" />
<h:message for="inp2" showSummary="false" showDetail="true" />
更多 message 信息
messages

h:messages用于显示所有消息。
使用示范代码:
<h:messages id="messageAll" showDetail="true" showSummary="true"/>
更多 messages 信息
outputFormat

outputFormat
产生指定的文字信息,可以搭配<f:param>来设定信息的参数以格式化文字信息,
例如:
<f:loadBundle basename="messages" var="msgs"/>
<h:outputFormat value="#{msgs.welcomeText}">
<f:param value="Hello"/>
<f:param value="Guest"/>
</h:outputFormat>
更多 outputFormat 信息
outputLabel

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">
更多 outputLabel 信息
outputLink

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绑定。
更多 outputLink 信息
outputText

outputText
简单的显示指定的值或绑定的信息,例如:
<h:outputText value="#{user.name}"/>
更多 outputText 信息
panelGrid

<h:panelGrid>
这个标签可以用来作简单的组件排版,它会使用HTML表格标签来绘制表格,并将组件置于其中,主要指定columns属性。
例如:
<h:panelGrid columns="2">
<h:outputText value="Username"/>
<h:inputText id="name" value="#{userBean.name}"/>
。。。。</h:panelGrid>

panelGroup

<h:panelGroup>
这个组件用来将数个JSF组件包装起来,使其看来像是一个组件,例如:
<h:panelGroup>
<h:commandButton value="submit" action="login"/>
<h:commandButton value="reset" type="reset"/>
</h:panelGroup>
更多 panelGroup 信息
selectBooleanCheckbox

<h:selectBooleanCheckbox>在视图上呈现一个复选框。
例如:
我同意 <h:selectBooleanCheckbox value="#\{user.aggree\}"/>
value所绑定的属性必须接受与传回boolean类型
更多 selectBooleanCheckbox 信息
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>
更多 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>
更多 selectManyListbox 信息
selectManyMenu

这个标签提供使用者复选项目的功能。
例子如下:
<h:selectManyMenu layout="pageDirection"
value="#{user.preferColors}">
<f:selectItem itemLabel="红" itemValue="false"/>
<f:selectItem itemLabel="黄" itemValue="false"/>
<f:selectItem itemLabel="蓝" itemValue="false"/>
</h:selectManyMenu>
更多 selectManyMenu 信息
selectOneListbox

selectOneListbox为单选列表框。
使用示范代码:
<h:selectOneListbox layout="pageDirection" value="#{user.education}">
<f:selectItem itemLabel="高中" itemValue="高中"/>
<f:selectItem itemLabel="大學" itemValue="大學"/>
<f:selectItem itemLabel="研究所以上" itemValue="研究所以上"/>
</h:selectOneListbox>
更多 selectOneListbox 信息
selectOneMenu

selectOneMenu 为下拉框,,和HTML的下拉框一样。
使用示范代码:
<h:selectOneMenu layout="pageDirection" value="#{user.education}">
<f:selectItem itemLabel="高中" itemValue="高中"/>
<f:selectItem itemLabel="大學" itemValue="大學"/>
<f:selectItem itemLabel="研究所以上" itemValue="研究所以上"/>
</h:selectOneMenu>
更多 selectOneMenu 信息
selectOneRadio

selectOneRadio为单选按钮集,类似网页的<input type="radio" ....
使用示例如下:
<h:selectOneRadio value="#{user.education}">
<f:selectItem itemLabel="高中" itemValue="高中"/>
<f:selectItem itemLabel="大学" itemValue="大学"/>
<f:selectItem itemLabel="研究所以上" itemValue="研究所以上"/>
</h:selectOneRadio>
更多 selectOneRadio 信息
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值