收藏 分销(赏)

JSF标签详解(全).doc

上传人:仙人****88 文档编号:8892562 上传时间:2025-03-06 格式:DOC 页数:13 大小:106.54KB 下载积分:10 金币
下载 相关 举报
JSF标签详解(全).doc_第1页
第1页 / 共13页
JSF标签详解(全).doc_第2页
第2页 / 共13页


点击查看更多>>
资源描述
Jsf标签详解(全)  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>   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>  convertDateTime  f:convertDateTime标签用来转换日期格式。 示范代码: <h:outputText value="#{bean.outputDate}">       <f:convertDateTime           pattern="yyyy年MM月dd日"/> </h:outputText>   converter  JSF可以使用 f:converter简单地调用指定onverter-id的JSF Converter实现(实现javax.faces.convert.Converter接口的类)对JSF组件组件的输入输出值加以变换。 示范代码: <h:inputText value="123456">         <f:converter converterId="myConverterId" />   </h:inputText>  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}"                 onclick="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> · 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="#{mandText}" 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="#{mand}"/>  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>    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 
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服