隨筆 - 25  文章 - 32  trackbacks - 0
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(2)

          隨筆檔案

          文章分類

          文章檔案

          相冊

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          在Eclipse生成的代碼中頁面是使用facelets、richFaces等編寫的,所以頁面使用的文件格式是xhtml。而非jsp。當然了,你也可以是用jsp編寫。這些生成的xhtml全部都在WebContent下

             首先看home.xhtml。

          1. <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          2.                 xmlns:s="http://jboss.com/products/seam/taglib"
          3.                 xmlns:ui="http://java.sun.com/jsf/facelets"
          4.                 xmlns:f="http://java.sun.com/jsf/core"
          5.                 xmlns:h="http://java.sun.com/jsf/html"
          6.                 xmlns:rich="http://richfaces.org/rich"
          7.                 template="layout/template.xhtml">
          8. </ui:composition>

          ui:composition元素:UI組件,使用這個元素做根元素表示這個頁面并不是一個完整的頁面,而是需要一個template頁面作為摸版的內容頁面。

                  xmlns:根元素命名空間。就是那些不帶前綴標簽比如<div>

                   xmlns:s:Seam元素的命名空間。

                  template:摸版頁面

          摸版頁面:

          1. <html xmlns="http://www.w3.org/1999/xhtml"
          2.       xmlns:ui="http://java.sun.com/jsf/facelets"
          3.       xmlns:h="http://java.sun.com/jsf/html"
          4.       xmlns:f="http://java.sun.com/jsf/core"
          5.       xmlns:s="http://jboss.com/products/seam/taglib">
          6. <head>
          7.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
          8.     <title>SeamTest</title>
          9.     <link href="stylesheet/theme.css" rel="stylesheet" type="text/css" />
          10. </head>
          11. <body>
          12.     <ui:include src="menu.xhtml">
          13.         <ui:param name="projectName" value="SeamTest"/>
          14.     </ui:include>
          15.     <div class="body">
          16.         <ui:insert name="body"/>
          17.     </div>
          18.     <div class="footer">
          19.         Powered by <a href="http://jboss.com/products/seam">Seam</a>.
          20.         Generated by seam-gen.
          21.     </div>
          22. </body>
          23. </html>

          ui:include:與<jsp:include>差不多。但這里沒有引入jsp命名空間。所以使用<ui:include>。

          <ui:insert/>:這個是一個template頁面。這個標簽表示插入一個名為body的內容塊。在內容頁面--home.xhtml--與此對應的是:<ui:define name="body"></ui:define>。在Seam-gen生成的頁面中幾乎所有的頁面都將template指向template.xhtml。還有另一種使用摸板的方式。比如layout/edit.xhtml。

          1. <ui:composition  xmlns="http://www.w3.org/1999/xhtml"
          2.                  xmlns:ui="http://java.sun.com/jsf/facelets"
          3.                  xmlns:h="http://java.sun.com/jsf/html"
          4.                  xmlns:f="http://java.sun.com/jsf/core"
          5.                  xmlns:s="http://jboss.com/products/seam/taglib">
          6.     <div class="prop">
          7.         <s:label styleClass="name #{invalid?'errors':''}">
          8.             <ui:insert name="label"/>
          9.             <s:span styleClass="required" rendered="#{required}">*</s:span>
          10.         </s:label>
          11.         <span class="value #{invalid?'errors':''}">
          12.             <s:validateAll>
          13.                 <ui:insert/>
          14.             </s:validateAll>
          15.         </span>
          16.         <span class="error">
          17.             <h:graphicImage value="/img/error.gif" rendered="#{invalid}" styleClass="errors"/>
          18.             <s:message styleClass="errors"/>
          19.         </span>
          20.     </div>
          21. </ui:composition>

           

          這里依然是使用<ui:insert />作為內容頁面的插入塊。這里有兩塊<ui:insert />第一塊是有name屬性的,第二塊則是沒有name屬性的。如果沒有name屬性,表示在插入塊中沒有放在<ui:defind/》里的東西都放在沒有name的插入塊中。。。比如

          1.             <s:decorate id="nameDecoration" template="layout/edit.xhtml">
          2.                 <ui:define name="label">Name</ui:define>
          3.                 <h:inputText id="name" required="true"
          4.                              value="#{bookHome.instance.name}"/>
          5.             </s:decorate>

           

          這里<ui:defind name="label">這就是定義那個有名字的插入塊。而接下來的<h:inputText ... />則是放在了下面沒有名字的<ui:insert />中。上面的代碼也展示了使用摸板的另一種方式。使用<s:decorate/>使用摸板塊,摸板頁面的根需要是一個<ui:composition>元素。s:decorate是一個seam元素。必須在seam的管理的頁面中使用。

          其他:

               jsf中的form是不需要action的。比如<h:form id="login">

              標簽的rendered屬性表示在什么情況下顯示。html標簽沒有rendered屬性,比如div標簽沒有rendered。

          其他的jsf標簽我們可以通過學習jsf學習。因為jsf標簽,richFaces標簽,faceslet標簽太多了。這里就不一一介紹了。。。。大家有什么好的資料也麻煩告訴我哦。

          posted on 2008-12-15 09:15 phyeas 閱讀(824) 評論(2)  編輯  收藏 所屬分類: Seam項目實戰

          FeedBack:
          # re: Seam新手實戰(2):自動生成的代碼2-xhtml文件 2008-12-17 12:46 小朱
          哈哈,正缺這方面的資料呢,謝謝了~~
          期待下一篇資料  回復  更多評論
            
          # re: Seam新手實戰(2):自動生成的代碼2-xhtml文件 2008-12-17 18:22 phyeas
          @小朱
          不用謝。呵呵  回復  更多評論
            
          主站蜘蛛池模板: 迁安市| 永新县| 廊坊市| 陆良县| 芒康县| 刚察县| 平定县| 凭祥市| 辽源市| 贡嘎县| 博客| 潮州市| 海晏县| 榆中县| 屯留县| 河曲县| 东台市| 永兴县| 石渠县| 白水县| 贵德县| 衡阳县| 宁陵县| 霍邱县| 育儿| 西和县| 黄平县| 蕲春县| 和田市| 京山县| 德庆县| 嘉善县| 克拉玛依市| 凌海市| 宿州市| 东宁县| 米林县| 杭锦旗| 九江市| 河北区| 垫江县|