JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Web Framework » JSF  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
己加入精華區
by browser at 2007-02-13 16:45
本主題所含的標籤
無標籤
作者 [分享] 將 Core JSF 第8章 book viewer tiles 範例 修改為 Tiles 2版 [精華]
bee





發文: 42
積分: 8
於 2007-02-13 16:34 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Smile
因小弟想練習 Core JSF 第8章 book viewer tiles, 發現 有新的 Tiles 2版,
而且完全不依賴 struts, 故嘗試將舊範例使用新版本執行 , 經一番努力後終於成功,
特將此方法與步驟寫下, 希望對各位大大有幫助.

首先 Tiles 2 版已經改了位置,改至 Sandbox area, url 如下
http://struts.apache.org/struts-sandbox/tiles/index.html

為了減少檔案範例大小, chapterX.html 只列出標頭沒有內容, 也不帶 ../lib/*.jar

說明步驟如下:
A.下載範例 Tiles 2:
http://people.apache.org/repo/m2-snapshot-repository/org/apache/struts/tiles/tiles-test/2.0-SNAPSHOT/
tiles-test-2.0-20061110.192427-7.war

B.為了方便, 請改名:
tiles-test-2.0-20061110.192427-7.war 改為 tiles-test.war

C.將 tiles-test.war 置於 {tomcat}/webapps/下

D.重新啟動 tomcat, 會自動產生{tomcat}/webapps/tiles-test 專案

E.環境:
WinXP-SP2, Tomcat-5.5, Eclipse-3.2(UTF-8), java-5(jre1.5.0_10)

F.修改步驟如下:
1.修改 Eclipse lib -> Project/Properties/Libraries/
刪除原所有 ../lib 下 *.jar
複製 範例內所有 ../lib/*.jar, 應該有如下 jar

commons-beanutils-1.7.0.jar
commons-collections-2.1.jar
commons-digester-1.7.jar
commons-logging-1.0.4.jar
jstl-1.1.2.jar
standard-1.1.2.jar
tiles-api-2.0-SNAPSHOT.jar
tiles-core-2.0-SNAPSHOT.jar
xml-apis-1.0.b2.jar


不要忘了要再加入
jsf-api.jar
jsf-impl.jar


2.修改web.xml:
原為:
1
2
3
4
5
6
7
8
9
  <servlet>
      <servlet-name>Tiles Servlet</servlet-name>
      <servlet-class>org.apache.struts.tiles.TilesServlet</servlet-class>
      <init-param>
         <param-name>definitions-config</param-name>
         <param-value>/WEB-INF/tiles.xml</param-value>
      </init-param>
      <load-on-startup>2</load-on-startup>
   </servlet>   

修改:
1
2
3
4
5
6
7
8
9
 <servlet>
      <servlet-name>tiles</servlet-name>
      <servlet-class>org.apache.tiles.servlet.TilesServlet</servlet-class>
      <init-param>
         <param-name>definitions-config</param-name>
         <param-value>/WEB-INF/tiles-defs.xml</param-value>
      </init-param>
      <load-on-startup>2</load-on-startup>
   </servlet>     


3.tiles.xml 改為 tiles-defs.xml

4.修改 tiles-defs.xml
1
2
3
4
5
 <!DOCTYPE tiles-definitions PUBLIC
     "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
     "http://struts.apache.org/dtds/tiles-config_2_0.dtd">
 
  <definition name="book" template="/headerMenuContentLayout.jsp">  


5.修改 book.jsp
原為:
1
2
3
4
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
    <h:form>
      <tiles:insert definition="book" flush="false"/>
    </h:form> 

修改:
1
2
3
4
   <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>    
    <h:form>
      <tiles:insertDefinition name="book" flush="false"/>
    </h:form>    

6.修改 headerMenuContentLayout.jsp
原為:很多個...
1
2
   <%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
   <tiles:insert attribute="header" flush="false"/>    

修改:
1
2
  <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>    
   <tiles:attribute name="header" flush="false"/>    


thanks! Smile

book-viewer-tiles.zip (12.3k)


reply to postreply to post
作者 Re:[分享] 將 Core JSF 第8章 book viewer tiles 範例 修改為 Tiles 2版 [Re:bee]
bee





發文: 42
積分: 8
於 2007-02-14 12:14 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Tongue
小弟本篇進入精華,版主大大是否忘了加分?
增加積分是讓自己加重對本站的參與心榮譽感
Dead


bee edited on 2007-02-14 21:36
reply to postreply to post
作者 Re:[分享] 將 Core JSF 第8章 book viewer tiles 範例 修改為 Tiles 2版 [Re:bee]
bee





發文: 42
積分: 8
於 2007-03-03 15:47 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Smile

發現一個對 tiles 說明(初級到進階)非常詳細的網站(英文),
對有需要的大大希望有助益:
http://www2.lifl.fr/~dumoulin/tiles/index.html

Big Smile


bee edited on 2007-03-03 15:51
reply to postreply to post
作者 Re:[分享] 將 Core JSF 第8章 book viewer tiles 範例 修改為 Tiles 2版 [Re:bee]
bee





發文: 42
積分: 8
於 2007-03-03 16:44 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Smile

一個CD商店的範例, 利用 jsf+tiles 並融入 div(非table) 及 css 來作分割顯示,
下載位置:http://www-128.ibm.com/developerworks/java/library/j-jsf2/
下載檔案: jsf-example2WithJars.zip,
解壓後 target/jsf-example2-1.0.war 檔案, 放到 {tomcat}/webapps 下
重新啟動 tomcat , 就可看到範例.

有簡體說明(不建議由此下載範例, 某些文字被改簡體, 列印易有亂碼)
http://www.java3z.com/cwbwebhome/article/article1/cd1.html?id=70

希望對各位大大有幫助!(這範例是 1.1 版 非 tiles 2 版)

Big Smile


reply to postreply to post
作者 Re:[分享] 將 Core JSF 第8章 book viewer tiles 範例 修改為 Tiles 2版 [Re:bee]
liny





發文: 205
積分: 0
於 2007-03-26 23:10 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Bee,你好:
我下載了你的範例book-viewer-tiles.zip
並把下列的jar放到WEB-INF/lib底下:
commons-beanutils-1.7.0.jar
commons-collections-2.1.jar
commons-digester-1.7.jar
commons-logging-1.0.4.jar
jsf-api.jar
jsf-impl.jar
jstl-1.1.2.jar
standard-1.1.2.jar
tiles-api-2.0-SNAPSHOT.jar
tiles-core-2.0-SNAPSHOT.jar
xml-apis-1.0.b2.jar

其中使用Sun的JSF 1.1.01
jre 1.6
Tomcat 5.5.20

但發生下列例外:
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet.init() for servlet Faces Servlet threw exception
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
  org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
  org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
  org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
  org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
  org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
  java.lang.Thread.run(Thread.java:619)

root cause

java.lang.NullPointerException
  javax.faces.webapp.FacesServlet.init(FacesServlet.java:144)
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
  org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
  org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
  org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
  org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
  org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
  java.lang.Thread.run(Thread.java:619)

note The full stack trace of the root cause is available in the Apache Tomcat

好像是FacesServlet是null,
但不知道怎麼解決,
能請您幫我看一下錯在哪裡嗎?


reply to postreply to post
[當一個人要離開的時候,總會有理由的]
作者 Re:[分享] 將 Core JSF 第8章 book viewer tiles 範例 修改為 Tiles 2版 [Re:bee]
koji

秒速5センチメートル

站長

發文: 8415
積分: 19
於 2007-03-27 00:02 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
http://www.javaworld.com.tw/jute/post/view?bid=42&id=40374&sty=1&tpg=1&age=-1

看看這個?

koji


reply to postreply to post
JCConf Taiwan 2015 開始售票了!!
Facebook上的TWJUG社團,歡迎加入
作者 Re:[分享] 將 Core JSF 第8章 book viewer tiles 範例 修改為 Tiles 2版 [Re:koji]
liny





發文: 205
積分: 0
於 2007-03-28 23:24 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
koji wrote:
http://www.javaworld.com.tw/jute/post/view?bid=42&id=40374&sty=1&tpg=1&age=-1

看看這個?

koji


恩~可以了,謝謝…


reply to postreply to post
[當一個人要離開的時候,總會有理由的]
作者 Re:[分享] 將 Core JSF 第8章 book viewer tiles 範例 修改為 Tiles 2版 [Re:bee]
godslayer





發文: 3
積分: 0
於 2007-08-29 18:29 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
大哥,小弟在读CORE jsf 2nd第八章卡住了,下的原代码儿凡是跟tiles有关的在netbean 6.0 m10的环境下都运行不了,说什么404错误,找不到资源还有服务,怎么办呀,去官网的FAQ看,居然连FAQ都没出来,怎么解决?谢谢。

reply to postreply to post
» JWorld@TW »  Web Framework » JSF

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8