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 = - This documentation serves as a high level resource to help Struts programmers to understand differences between Struts and Tapestry (3.0). + 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, + hoping that it will help somebody in the same situation. - = Foreword = + (This page was started by EdYu, but left mostly empty for two years, so I am going to write it. MartinKuba) - I have been a Struts programmer for a couple of years and I'm now looking for the next technology in web user interface development. While JSF sounds promising, it is still too early to commit to it IMO. Before diving into Struts years ago, I have looked at Tapestry and found myself unable to understand it. At that time, I'm just like everyone else, coming from a CGI programming background, that's why Struts seems to be a relatively easy framework to understand. A couple of years has passed and now I'm looking into Tapestry and find that it all makes sense! Hopefully, this article illustrates the similarities and differences between the two frameworks. + = Tapestry advantages over Struts = - PS. I'm a Tapestry newbie, so please if you find anything incorrect, inaccurate or needs to be further explained, you are encouraged to correct it, or email me so I can correct it ([EMAIL PROTECTED]). + You need much less writing compared to Struts. Imagine the typical example of a page with a form for editing a database record. In Struts, you need to create: + 1. a '''form bean''' for holding data entered into the form, i.e. a Java class extended from ActionForm + 1. an '''action''' for getting the record from a database and prefiling the form bean + 1. a '''JSP page''' for displaying the form + 1. a second '''action''' for storing the modified data back into the database + 1. a '''<form-bean>''' definition in struts-config.xml + 1. two '''<action>'''definitions in struts-config.xml + 1. a page '''<definition>''' definition in tiles-config.xml - = Architecture Comparison = + That's a lot of typing, and in many places, which must be synchronized. In Tapestry, you need to write: - Struts is based on the HTTP model (or more accurately Sun's Servlet API). The core idea is using the Struts controller servlet and its configuration file (struts-config.xml) to examine URLs (or HTTP form posts), instantiate a java bean (subclass of Action``Form) and set its properties using the URL parameters (or HTTP form post), invoke data validation method defined within the Action``Form, and then pass it along to a java class (subclass of Action or Lookup``Dispatch``Action) defined within the Struts configuration file (struts-config.xml) and finally looks up and dispatch to a destination view, typically a jsp page (there are other view technologies that are compatible with Struts, please refer to the Struts web site for more information). So it should be fair to say that Struts is action oriented (URL.do -> action.java -> destination.jsp). + 1. a form bean + 1. a page template (MyPage.html) + 1. a page class (MyPage.java) - Tapestry takes a slightly different approach. The architecture centered around the page. + 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), + 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. - = Comparisons = + - This section attempts to roughly compare the similarities and differences between the 2 frameworks. - - == Conceptual Comparison == - - === Struts Modules vs. Tapestry Application === - - === Taglibs vs. Tapestry Components === - - === JSP vs. HTML Template === - - == Developmental Comparison == - - === struts-config.xml vs. app.application === - - === JSP vs. page.html + page.page === - - === ActionForm.java + Action.java vs. page.java === - - === Form initialization === - - === Form validation === - - === Session vs. Visit.java === - - === ServletContext vs. Global.java === - - === Internationalization(I18N)/Localization(L10N) === - - = Conclusions = - --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
