Sorry, this project is no longer updated! First of all, this project is initially created as a proof of concept of using XSLT to perform the coding generations. It has already served its purpose. Secondly, there are other more mature choices, such as Easy Struts at http://easystruts.sourceforge.net Thanks for your support and Good luck with you. Bye for now, Shengmeng Liu
Struts XSLT Code Generator, is an XSLT based code generator for Struts. This generator uses an extended version of struts-config.xml file to specify the information needed to generate codes for most types struts files, such as ActionForm class, Action class, JSP and etc. Moreover, The generated code may uses the validator framework for form validation.
The most important characteristic or advantage of this generator is that the code generation is completely based XSLT transformation and a set of stylesheet files. So that users do not have to access the source code and recompile the program to customize the templates for each type of struts files.
This generator is mainly based on XSLT transformation by applying xsl template files. Basically, It first uses the JDOM API to build a JDOM document from the struts-config.xml (extented version) and then perform XSLT transformations on this JDOM document iteratively, each time it will apply certain type of XSL template file and pass in different parameters to generate each kind of Struts files. There will be one specific xsl file for generating each type of struts files (namely, ActionForm class, Action class, JSPs, validation.xml and etc.)
In the Struts model, there are 3 components ( JSP, ActionForm class, Action class) in the web tier that need and are suitable for code generation. Among them, the ActionForm class is the key (linking) part. As JSP will submit the form data into it and the Action class will retrieve its input parameters from it. Therefore, the basis of code generation configuration is the definition of ActionForm. After that, JSP is generated as the partial view of that form and Action class can also be derived from its associated ActionForm class in the ActionMapping. This is actually in accordance with the principle of data/model driven programming, as ActionForm is the essential data model of web tier.
My proposed extended ActionForm (form-bean elment) is actually an implementation of the suggestion provided in the struts-config.xml of the example application distributed with the Struts. That is to define the form-bean element of struts-config.xml in a flesh out fashion. Specifically, form-bean element now have sub-elements named jsp, which associates with the jsp files submitted to this form-bean. The jsp element has one attribute named path which points to the file path of this jsp file. Within the jsp element, you can define sub-element called element, which represents the form field in the jsp file. Each element has two attributes one is type (for field type), another is property of the form-bean.
So now all the information needed for the code generation is in the struts-config.xml.
Sample struts-config.xml: ( with extended the form-bean element) which defines a two-page registration form:
<form-bean name="registerForm" type="org.smliu.struts.form.RegisterForm" > <jsp path="/register1.jsp"> <element type="text" property="name"/> <element type="checkbox" property="subscribe" /> </jsp> <jsp path="/register.jsp"> <element type="text" property="username"/> <element type="password" property="password" /> </jsp> </form-bean>Download XSLT Code Generator 0.85
Go to Project page on the SourceForge