Dear Wiki user, You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.
The following page has been changed by ErikVullings: http://wiki.apache.org/tapestry/TapestryFasttrackForStrutsProgrammers ------------------------------------------------------------------------------ - = Tapestry Fast Track for Struts Programmers = + = Foreword = I am in the process of converting from Struts (1.2) to Tapestry (4.0) right now. I found the Tapestry documentation lacking in several places, namely about HiveMind, how to provide consistent desing for all pages as in Tiles etc. So I provide here the steps needed for transition from Struts to Tapestry, @@ -25, +25 @@ 1. a page template (MyPage.html) 1. a page class (MyPage.java) - That's all ! No configuration file needed, if you use annotations. How is that possible ? Because the page and the class has the same name (MyPage), + That's all ! No configuration file needed, if you use annotations. How is that possible ? Because the page and the class have the same name (MyPage), + they belong together, so you don't need the <action> definitions from Struts. You can place the code of both two actions, form initialization and data saving, into just one class instead of two. The form bean used is specified in the code, so you don't need the <form-bean> definition. And you don't need the Tiles definition, because page composition is given by the page template. - they belong together, so you don't need the <action> definitions from Struts. You can place both two actions, form initialization and data saving, into the same class, - so you need only one class instead of two. The used form bean is specified in the code, so you don't need the <form-bean> definition. And you don't need the Tiles definition, because page composition is given by the page template. - + = Application setup = + Here is what you need to do to create a new web application in Tapestry. First you need the following JAR files in the WEB-INF/lib/ directory: {{{ + WEB-INF/lib/commons-codec-1.3.jar + WEB-INF/lib/commons-fileupload-1.1.jar + WEB-INF/lib/commons-io-1.1.jar + WEB-INF/lib/commons-logging-1.0.4.jar + WEB-INF/lib/hivemind-lib-1.1.1.jar + WEB-INF/lib/hivemind-1.1.1.jar + WEB-INF/lib/javassist-3.0.jar + WEB-INF/lib/junit-3.8.1.jar + WEB-INF/lib/log4j-1.2.13.jar + WEB-INF/lib/ognl-2.6.7.jar + WEB-INF/lib/oro-2.0.8.jar + WEB-INF/lib/tapestry-annotations-4.0.2.jar + WEB-INF/lib/tapestry-contrib-4.0.2.jar + WEB-INF/lib/tapestry-4.0.2.jar}}} + + Then, if you want to use the ''friendly URLs'' in Tapestry (and I bet you want) you need your WEB-INF/web.xml looking in this way: {{{ + <?xml version="1.0" ?> + <web-app xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" + version="2.4"> + <servlet> + <servlet-name>app</servlet-name> + <servlet-class>org.apache.tapestry.ApplicationServlet</servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + <filter> + <filter-name>redirect</filter-name> + <filter-class>org.apache.tapestry.RedirectFilter</filter-class> + </filter> + <filter-mapping> + <filter-name>redirect</filter-name> + <url-pattern>/</url-pattern> + </filter-mapping> + <servlet-mapping> + <servlet-name>app</servlet-name> + <url-pattern>/app</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>app</servlet-name> + <url-pattern>*.html</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>app</servlet-name> + <url-pattern>*.direct</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>app</servlet-name> + <url-pattern>*.sdirect</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>app</servlet-name> + <url-pattern>*.svc</url-pattern> + </servlet-mapping> + </web-app>}}} + + You also need a file WEB-INF/hivemodule.xml with the following content: {{{ + <?xml version="1.0"?> + <module id="tapestryapp" version="1.0.0"> + <!-- for friendly URLs --> + <contribution configuration-id="tapestry.url.ServiceEncoders"> + <page-service-encoder id="page" extension="html" service="page"/> + </contribution> + <contribution configuration-id="tapestry.url.ServiceEncoders"> + <direct-service-encoder id="direct" stateless-extension="direct" stateful-extension="sdirect"/> + </contribution> + <contribution configuration-id="tapestry.url.ServiceEncoders"> + <extension-encoder id="extension" extension="svc" after="*"/> + </contribution> + </module> + }}} + + And the last configuration file is named WEB-INF/app.application, and you need to specify here the Java class packages, which will be searched for pages and components. + I also specify the template encoding here, as I need to write accented characters in my native language. {{{ + <?xml version="1.0"?> + <!DOCTYPE application PUBLIC + "-//Apache Software Foundation//Tapestry Specification 4.0//EN" + "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"> + + <application name="My application"> + <description>My Wonderful Application</description> + <meta key="org.apache.tapestry.page-class-packages" value="com.mydomain.myproject.pages"/> + <meta key="org.apache.tapestry.component-class-packages" value="com.mydomain.myproject.components"/> + <meta key="org.apache.tapestry.template-encoding" value="iso-8859-2"/> + </application>}}} + + If you want to internationalize your application, it means to provide localized texts in several languages, you can create ResourceBundle files + *WEB-INF/app.properties + *WEB-INF/app_en.properties + *WEB-INF/app_cs.properties + * ... + + which will hold the localized texts common for the whole application. You can also put the localized texts into files specific to each page or component. + + That's the whole configuration. + + = Component for accessing JSPs = + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
