JSF标签详解一个不漏.docx
- 文档编号:30676178
- 上传时间:2023-08-19
- 格式:DOCX
- 页数:16
- 大小:21.40KB
JSF标签详解一个不漏.docx
《JSF标签详解一个不漏.docx》由会员分享,可在线阅读,更多相关《JSF标签详解一个不漏.docx(16页珍藏版)》请在冰豆网上搜索。
JSF标签详解一个不漏
Jsf标签详解(一个不漏)
整理来自:
www.web-
actionListener
f:
actionListener标签为h:
commandLink,h:
commandButton等指定自定义的事件侦听类。
f:
actionListener使用:
JSP:
commandButtonid="regist"value="Regist"> actionListenertype="mypackage.ActionListenerImpl"> actionListener>
commandButton>
更多 actionListener 信息
attribute
f:
attribute标签用来设置父标签的属性。
f:
attribute标签使用例:
JSP:
graphicImageurl="/images/picture.jpg"> attributename="height"value="20"/> attributename="width"value="10"/>
graphicImage>
更多 attribute 信息
convertDateTime
f:
convertDateTime标签用来转换日期格式。
示范代码:
outputTextvalue="#{bean.outputDate}"> convertDateTime pattern="yyyy年MM月dd日"/>
outputText>
更多 convertDateTime 信息
converter
JSF可以使用f:
converter简单地调用指定onverter-id的JSFConverter实现(实现javax.faces.convert.Converter接口的类)对JSF组件组件的输入输出值加以变换。
示范代码:
inputTextvalue="123456"> converterconverterId="myConverterId"/>
inputText>
更多 converter 信息
convertNumber
f:
convertNumber用来对数字,通货等等进行格式转换
示范代码:
inputText value="123456"> convertNumber type="currency" currencySymbol="$"/>
inputText>
更多 convertNumber 信息
facet
f:
facet标签用来为包含f:
facet标签的父组件与被f:
facet标签所包含的子组件之间申明一种特殊的关系。
常与h:
panelGrid,h:
dataTable等标签连用,申明组件为标题或页脚。
示范代码:
facetname="header"> outputTextvalue="Title"/>
facet>
更多 facet 信息
loadBundle
f:
loadBundle是JSF提供的一个支持JSP本地化(多语言支持)操作的标签。
示范代码:
loadBundlebasename="com.test.resource.Messages"var="msg"/> 更多 loadBundle 信息 param f: param用于向组件添加参数。 一般用法主要有2种: outputLinkvalue="/someUrl"> paramname="id"value="#{bean.id}"/> paramname="name"value="#{bean.name}"/> outputLink> 或 outputFormatvalue="Youhave{0}itemsinyourshoppingcart."> paramvalue="#{SessionBean1.cart.itemCount}"/> outputFormat> 更多 param 信息 selectItem f: selectItem指定UISelectOne或UISelectMany组件的一个项目,用来为h: selectOneMenu等选择性组件设置选择数据项。 示范代码: selectOneMenu value="#{bean.selectedItemValue}"> selectItemitemLabel="Label1"value="0"/> selectItemitemLabel="Label2"value="1"/> selectOneMenu> 更多 selectItem 信息 selectItems f: selectItems用于指定UISelectOne或UISelectMany组件的多个项目, 与f: selectItem标签一样,用来为 -h: selectManyCheckbox -h: selectManyListbox -h: selectManyMenu -h: selectOneListbox -h: selectOneMenu -h: selectOneRadio 等设置数据项。 更多 selectItems 信息 subview 可以使用f: subview包含指定的JSF页面,或者其他JSF组件。 使用f: subview包含JSF页面时,被包含的页面里只能包含有JSF组件,所有非JSF组件元素必须用f: verbatim标签进行转换。 示范代码: subviewid="id3"> <%@includefile="subpage.jsp"%> subview> 更多 subview 信息 validateDoubleRange f: validateDoubleRange可以对所有输入类型的组件的输入值加以验证。 f: validateDoubleRange必须被包含在上述输入组件之内。 例: inputTextid="amount"value="#{mybean.amount}"required="true"> validateDoubleRangemaximum="2500.8"minimum="0.00"> validator> inputText> 更多 validateDoubleRange 信息 validateLength 示范代码: inputTextid="userId"value="#{mybean.userId}"required="true"> validateLengthmaximum="16"minimum="8"/> inputText> 更多 validateLength 信息 validateLongRange f: validateLongRange可以对所有输入类型的组件的输入值加以验证。 f: validateLongRange必须被包含在上述输入组件之内。 例: inputTextid="amount"value="#{mybean.amount}"required="true"> validateLongRangemaximum="2500"minimum="800"/> inputText> 更多 validateLongRange 信息 valueChangeListener valueChangeListener 向父组件注册值变更监听器。 示范代码: selectBooleanCheckboxid="sbc_operate"value="#{pc_Attribute.selected}" valueChangeListener="#{pc_Attribute.onOperateSelectedChange}" onclick="submit();"> 更多 valueChangeListener 信息 verbatim 简单说来就是,标签里包含什么,就在网页上输出什么。 示范代码: verbatim> verbatim> 更多 verbatim 信息 view view用于创建顶层视图。 使用样例: view> column> outputTextvalue="#{user.name}"/> column> view> 更多 view 信息 ∙JSFForm column dataTable>配合 column>来以表格的方式显示数据, column>中只能包括JSF组件或者是 facet>,JSF支援两种facet: header与footer。 示范代码: dataTablevalue="#{tableBean.userList}"var="user"> column> facetname="header"> outputTextvalue="Name"/> facet> column> dataTable> 更多 column 信息 commandButton commandButton 显示一个命令按钮,即输出HTML标签,其type属性可以设定为button、submit或reset,预设是submit,按下按钮会触发javax.faces.event.ActionEvent,使用例子如下: commandButtonvalue="提交"action="#{user.verify}"/> 更多 commandButton 信息 commandLink commandLink 产生超链接,会输出HTML标签,而href属性会有'#'。 示范代码: commandLinkvalue="#{mandText}" action="#{user.verify}"/> 更多 commandLink 信息 dataTable 很多数据经常使用表格来表现,JSF提供 dataTable>标签让您得以列举数据并使用表格方式来呈现。 示范代码: dataTablevalue="#{tableBean.userList}"var="user"> column> outputTextvalue="#{user.name}"/> column> column> outputTextvalue="#{user.password}"/> column> dataTable> 更多 dataTable 信息 form form>和HTML里面的form,用于表单数据提交。 更多 form 信息 graphicImage graphicImage> 这个标签会绘制一个HTML标签,value可以指定路径或图片URL,路径可以指定相对路径或绝对路径,例如: graphicImagevalue="/images/logowiki.jpg"/> 更多 graphicImage 信息 inputHidden inputHidden 隐藏输入框,即输出HTML标签,其type属性设定为hidden,隐藏输入框的值用于保留一些信息于客户端,以在下一次发送表单时一并提交,例如: inputHiddenvalue="#{user.hiddenInfo}"/> 更多 inputHidden 信息 inputSecret inputSecret 显示密码输入框,即输出HTML标签,其type属性设定为password, 例如: inputSecretvalue="#{user.password}"/> 您可以设定redisplay属性以决定是否要显示密码栏目的值,预设是false。 更多 inputSecret 信息 inputText inputText显示单行输入框,即输出HTML标签,其type属性设定为text。 例如: inputTextvalue="#{user.name}"/> 更多 inputText 信息 inputTextarea inputTextarea 显示多行输入文字区域,即输出 inputTextareavalue="#{mand}"/> 更多 inputTextarea 信息 message 显示一个组件的最近使用的消息, 示范代码: inputTextid="inp2"/> messagefor="inp2"showSummary="false"showDetail="true"/> 更多 message 信息 messages h: messages用于显示所有消息。 使用示范代码: messagesid="messageAll"showDetail="true"showSummary="true"/> 更多 messages 信息 outputFormat outputFormat 产生指定的文字信息,可以搭配 param>来设定信息的参数以格式化文字信息, 例如: loadBundlebasename="messages"var="msgs"/> outputFormatvalue="#{msgs.welcomeText}"> paramvalue="Hello"/> paramvalue="Guest"/> outputFormat> 更多 outputFormat 信息 outputLabel outputLabel 产生 inputTextid="user"value="#{user.name}"/> outputLabelfor="user"value="#{user.name}"/> 这会产生像是以下的标签: 更多 outputLabel 信息 outputLink outputLink outputLinkvalue="../index.jsp"> outputTextvalue="LinktoIndex"/> paramname="name"value="MyName"/> outputLink> 你可搭配 param>帮链结加上参数,所有的参数都会变成name=value的类型附加在链接后。 value所指定的内容也可以是JSFEL绑定。 更多 outputLink 信息 outputText outputText 简单的显示指定的值或绑定的信息,例如: outputTextvalue="#{user.name}"/> 更多 outputText 信息 panelGrid panelGrid> 这个标签可以用来作简单的组件排版,它会使用HTML表格标签来绘制表格,并将组件置于其中,主要指定columns属性。 例如: panelGridcolumns="2"> outputTextvalue="Username"/> inputTextid="name"value="#{userBean.name}"/> 。 。 。 。 panelGrid> 更多 panelGrid 信息 panelGroup panelGroup> 这个组件用来将数个JSF组件包装起来,使其看来像是一个组件,例如: panelGroup> commandButtonvalue="submit"action="login"/> commandButtonvalue="reset"type="reset"/> panelGroup> 更多 panelGroup 信息 selectBooleanCheckbox selectBooleanCheckbox>在视图上呈现一个复选框。 例如: 我同意 selectBooleanCheckboxvalue="#\{user.aggree\}"/> value所绑定的属性必须接受与传回boolean类型 更多 selectBooleanCheckbox 信息 selectManyCheckbox 这个标签提供使用者复选项目的功能 例子如下: selectManyCheckboxlayout="pageDirection" value="#{user.preferColors}"> selectItemitemLabel="红"itemValue="false"/> selectItemitemLabel="黄"itemValue="false"/> selectItemitemLabel="蓝"itemValue="false"/> selectManyCheckbox> 更多 selectManyCheckbox 信息 selectManyListbox 这个标签提供使用者复选项目的功能 例子如下: selectManyListboxlayout="pageDirection" value="#{user.preferColors}"> selectItemitemLabel="红"itemValue="false"/> selectItemitemLabel="黄"itemValue="false"/> selectItemitemLabel="蓝"itemValue="false"/> selectManyListbox> 更多 selectManyListbox 信息 selectManyMenu 这个标签提供使用者复选项目的功能。 例子如下: selectManyMenulayout="pageDirection" value="#{user.preferColors}"> selectItemitemLabel="红"itemValue="false"/> selectItemitemLabel="黄"itemValue="false"/> selectItemitemLabel="蓝"itemValue="false"/> selectManyMenu> 更多 selectManyMenu 信息 selectOneListbox selectOneListbox为单选列表框。 使用示范代码: selectOneListboxlayout="pageDirection"value="#{user.education}"> selectItemitemLabel="高中"itemValue="高中"/> selectItemitemLabel="大學"itemValue="大學"/> selectItemitemLabel="研究所以上"itemValue="研究所以上"/> selectOneListbox> 更多 selectOneListbox 信息 selectOneMenu selectOneMenu为下拉框,,和HTML的下拉框一样。 使用示范代码: selectOneMenulayout="pageDirection"value="#{user.education}"> selectItemitemLabel="高中"itemValue="高中"/> selectItemitemLabel="大學"itemValue="大學"/> selectItemitemLabel="研究所以上"itemValue="研究所以上"/> selectOneMenu> 更多 selectOneMenu 信息 selectOneRadio selectOneRadio为单选按钮集,类似网页的 使用示例如下: selectOneRadiovalue="#{user.education}"> selectItemitemLabel="高中"itemValue="高中"/> selectItemitemLabel="大学"itemValue="大学"/> selectItemitemLabel="研究所以上"itemValue="研究所以上"/> selectOneRadio> 更多 selectOneRadio 信息
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JSF 标签 详解 一个