<facelet-taglib>
<namespace>http://xiangyun.cn/components</namespace>
<tag>
<tag-name>echo</tag-name>
<source>component.jspx</source>
</tag>
</facelet-taglib>
在這里引用了一個component.jspx文件,這個文件就是一個或一組想放在一塊當做一個組件使用的內容,和其他的jspx文件的寫法一樣。內容如下:
<ui:composition xmlns:ui="<ice:selectInputDate id="inputDate" popupDateFormat="MM/dd/yyyy"
value="#{inputDate}" renderAsPopup="true"
styleClass="iceSelInpDateInput" onkeydown="ctlent(event);"
rendered="true">
</ice:selectInputDate>
<h:outputText value="#{inputDate}"
rendered="true" styleClass="printText">
<f:convertDateTime dateStyle="long" type="date" timeZone="GMT+8"
locale="cn" />
</h:outputText>
</ui:composition>
只需要注意<ui:composition>標簽和引入的命名空間就行,標簽里面的內容就看你要完成的功能了。在這里我使用了ICEfaces的日期組件,可以替換成JSF支技的任何東西。
接下來就是要使用了。
<html xmlns="<ui:composition template="/pages/layout/layout.jspx">
<ui:define name="content">
<h:form id="testForm">
<ald:echo inputDate="#{testBean.date}"/>
</h:form>
</ui:define>
</ui:composition>
</html>
這里需要引入命名空間,定義前綴為ald,
<ald:echo>這個標簽名同xiangyun.taglib.xml中聲明的要一致,inputDate是在定義組件component.jspx中聲明的#{inputDate},它可以接收EL表達式。
這樣我們就可以把大的復雜的頁面,分成可以重用的組件了。
有問題可以和我聯系:wfn_libo@163.com
也可以參考https://facelets.dev.java.net/nonav/docs/dev/docbook.html#gettingstarted-bean
Technorati : facelets, jsf
posted on 2008-07-18 15:22
Libo 閱讀(2303)
評論(1) 編輯 收藏 所屬分類:
JavaServer Faces