在Tomahawk成功部署后,出于對界面的優化和增加一些功能亮點的需要,我開始考慮使用一些sandbox中的控件,本來按理說一切都應該很順利的,畢竟在此之前大部分問題都已經按部就班地做過了一遍,所有要改動的東西、以及哪些部分是做什么用的都已經清楚了,但結果還是出乎我的意料。

              先說說這個意外的結果吧,含sandbox 組件的頁面能夠顯示但沒有相應的效果,sandbox的組件看起來好像被忽略了,查看html源碼可知很多sandbox標簽沒有被正確解析,另外沒有任何錯誤或警告信息,無論在頁面還是在log中都沒有發現任何有用線索,額外加用facestrace也沒找到什么錯誤。

              配置步驟如下:
              1. 下載tomahawk-sandbox包,我先后試過兩個版本:1.1.5   和 1.1.6-snapshot
              2. 下載了facelets主站上的sandbox taglib文件,并且根據sandbox源碼仔細核對修改過,確信沒有了錯誤。
              3. 修改web.xml,在context-param 中為facelets.LIBRARIES,增加了相應的taglib.xml,最終信息像下面這樣
           <context-param>
            
          <param-name>facelets.LIBRARIES</param-name>
            
          <param-value>/WEB-INF/tomahawk.taglib.xml;/WEB-INF/sandbox.taglib.xml;/WEB-INF/jsf-comp-chart.taglib.xml;/WEB-INF/facestrace.taglib.xml</param-value>
           
          </context-param>
              以上配置中,除了sandbox,其他一切正常,另外還用了Ajax4JSF,但不管是否去掉它,對結果都沒有影響,已試驗過,不必再考慮這個因素。

              4. 在測試頁面中增加了namespace支持,加了點代碼用到sandbox, 片斷如下:

          <t:document       xmlns:t="http://myfaces.apache.org/tomahawk"
               xmlns:s
          ="http://myfaces.apache.org/sandbox"
          ..
          >
          <!-- effect by dojo -->
          <s:effect id="effect1" fade="true">
          <h:outputText value="Hello We hope you enjoy Apache MyFaces and the effects by DOJO and script.aculo.us" />
          </s:effect>
          <!--  input focus -->
          <h:panelGrid columns="2">
             
          <h:outputLabel for="input1" value="Input1: "/>
             
          <h:inputText id="input1"/>
             
          <h:outputLabel for="input2" value="Input2: "/>
             
          <h:inputText id="input2"/>
             
          <s:focus id="focus" for="input2" />
          </h:panelGrid>
          <!--  input suggest -->
          <s:inputSuggest value="#{user.state.key}" required="true">
             
          <f:selectItems value="#{choices}"/>
          </s:inputSuggest>

              5.并且在加入sandbox后,把以前的tomahawk-facelets.jar也從/WEB-INF/lib目錄下刪除試過,不刪除時有沖突提示,但就sandbox控件的顯示而言,結果是一樣的,“沒有!”

          有誰能有比較好的解決方案,還是我漏掉了什么重要的步驟,請不吝指教,非常感謝!

          另,希望上述這些配置方法對需要進行tomahawk,facestrace, jsf-comp在facelets中配置的人有些幫助!

          問題找到了,因為sandbox.taglib.xml中有錯誤,導致faceletViewHandler.initializeCompiler失敗,從而使用xmlns:s="http://myfaces.apache.org/sandbox能被識別,但里面的TagLibConfig卻沒有正確的內容,這樣facelet只好把部分標簽忽略了

          Feedback

          # re: 求教: 如何在Facelets中使用Tomhawk sandbox?  回復  更多評論   

          2007-06-04 11:23 by 小李飛刀
          在 facelets.dev.java.net(https://facelets.dev.java.net/nonav/docs/dev/docbook.html#taglib-use-normal)上有這么一段話

          If there is a tag in your document under a namespace (such as XHTML) that isn't specified in a Tag Library, then Facelets will treat that tag as a simple text fragment and optimize it for tree creation. If the namespace is known, but the element's name isn't included in the tag library, then an exception will be thrown which will tell you what file and line caused the problem.

          If your tag or component isn't showing up in your rendered page, check the source of page and see if the tag was simply ignored. This usually means you are using the wrong namespace for your library.

          從癥狀上來看,的確是把sandbox的tag當作了simple text直接輸出到了頁面,但我就是沒弄明白為什么會這樣,仔細檢查了namespace 和library,好像也沒發現什么錯誤。

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          posts - 44, comments - 43, trackbacks - 0, articles - 5

          Copyright © 小李飛刀

          涉足江湖,廣交朋友
          尋找有共同興趣愛好者一起開創掌上移動應用!


          歡迎光臨!您是第 hit counter 位訪客。
          主站蜘蛛池模板: 石屏县| 道真| 思南县| 喜德县| 西盟| 阿巴嘎旗| 河池市| 玛纳斯县| 满洲里市| 遵化市| 商河县| 顺昌县| 麻栗坡县| 洛阳市| 长汀县| 北辰区| 华池县| 利川市| 呼和浩特市| 砀山县| 屏东市| 望奎县| 察雅县| 任丘市| 衢州市| 思南县| 镇雄县| 葫芦岛市| 苗栗市| 建德市| 灌南县| 醴陵市| 宜宾市| 大荔县| 大厂| 剑河县| 江陵县| 宁远县| 修水县| 汪清县| 根河市|