What is StruXSLT?The basic idea was taken from an article published at www.javaworld.com. When using XML/XSLT instead of jsp, separation between view and the other layers of MVC-model is more strict.
StruXSLT is an extension for jakarta Struts, which should enable the usage of XSLT for the view-part of struts instead of jsp without changing or limiting the functionallity of struts. To use this package, a new base class has to be used instead of Struts' Action-class, but it is not necessary to exchange the ActionServlet (so registering struts within web.xml can be as is customary for Struts).
StruXSLT sits on top of Struts, extending its existing functionality to allow Action classes to return XML that will be transformed by technologies like XSL and XSL-FO. One motiviation to use q-struxsl is to remove the need to use JSP and tag libraries for the presentation layer of the Struts framework. However, q-struxsl does not force you to go the XML route, both technologies will work side by side.
The basic features of this framework are listed here:
- Language independency: all language tokens are set within external XML-files, which are weaved together with the content of the page to be visualized via XSLT afterwards. The settings to be done for linking language files to actions are described in section ``XSLT-map''.
- No JSP necessary: The main concept of the framework is to simply use XSLT for displaying information. Nevertheless usual Actions working with e.g. struts-taglibs can be used.
- AJAX-support: data generation and forwarding can be influenced by a action-parameter delivered when requesting the view
- support for debugging: several functions e.g. output the whole generated xml which is used for rendering directly within the browser.should help finding errors..
- predefined methods for influencing view, e.g. addAdditionalMenueEntries
- feedback functions: from every position within the action classes, message and error codes can be set and transferred to the view.
Action ClassesStruXSLT strictly separates between view-actions and process-actions, so two main base classes exist within the framework. This diagram should just give an overview of the methods to be overriden from the perspective of the user of the framework.
BaseStruXSLActionThis class serves as the base class for all action classes within the whole framework. Here, also an instance of the Session Manager is held, where basic settings for user session are stored. In general, messages, errors and other informations can be set from any action. All this information is transformed to XML and offered to the view-layer. So basic managing (like adding errors an messages) of all theses messages is implemented here.
BaseStruXSLViewActionUse this class as base class for all Actions generating (XML-) data. All information specific for a certain action is generated within the generateXML, so implement this abstract method in the project-specific view-class when overriding BaseStruXSLViewAction.
BaseStruXSLProcessActionThis is the base class for all actions which should process any data (which in general means writing information to the database or to the session). The abstract method doProcessData has to be overriden within the concrete subclass. As return value, an ActionForward constant is returned.
XSLT-mapthe central configuration file for the whole framework is xslt-map.xml, where the XML-generating action is weaved together with the stylesheet and language token documents to ensure language independence. Internally, one XML-document ist generated, which is rendered by the XSLT-document specified. A simple entry can be defined as shown in the following example:
<entry path="/basicsettingsv" type="simple" lang_file="admin/basicsettings.xml"> <xslt path="admin/basicsettings.xsl" /> </entry>
....to be continued :)