Hi,
based on the discussed API for Velocity for Struts I implemented
the context tools. I have put together a demo application that
incudes several small application examples as well as reference
documentation for the context tools. The demo can be downloaded
from

http://www.teamup.com/velstruts/velstruts.war [1.3 MB]

This is a ready-to-deploy war file. Put it into the webapps
directory of your favorite servlet container and restart. Then
point your browser at http://yourserver:port/velstruts/

While implementing the API I came across several weaknesses of
the discussed API. I made the changes outlined below. Please review
and yell if you feel something is going the wrong way. Please refer
to the reference documentation in the war files for details.

The code is now structured such that all Struts Know-How is 
kept in a class StrutsUtils. This is a utility class with all
static methods. All context tools use it to access to the 
Struts resources. This avoids the spreading of Struts Know How
all over. The methods of StrutsUtils reflect what Velocity context
tools need from Struts. I hope that at some point these 
utilities can be integrated into Struts itself. 

I introduced an abstract context tool ServletContextTool. All
Struts context tools extend ServletContextTool. It provides 
logging to the logging facility provided by the Servlet API. 
I am not fully satisfied yet with this approach. I think we
should forsee logging support already in the ContextTool interface.

My intention is now to wait for feedback, make necessary 
improvements and then commit this software to 
jakarta-velocity-tools within about a week.

My next planned steps are the following:
- setup test cases
- add documentation: overview, user guide, quick reference guide
- make documentation printable
- put together a binary distribution with examples and a blank 
  application and announce it to the world
- add ActionMessagesTool
- rework the current logging concept for context tools
- add capability to config Velocity
- remove Velocity's [INFO] logging for each template


Your feedback is appreciated.

Gabe




--------------------------------------------------------------------
API Changes in 0.6:

- MessageTool
    - Added method public get(String key, ArrayList args). It's more
      Velocity compatible than get(String key, Object[]). I left
      the latter to stay compatibility with existing apps.
    
- LinkTool:
    - Renamed setPath() to setURI(). This method takes absolute
      URIs, server-relative URIs, relative URIs and URIs with query
      parameters. The new name is more accurately reflecting what the
      method does.
    - Renamed getServerPath() to getContextURI(). This naming is 
      consistent with the naming used in the Servlet API and it seems
      also more intuitive.
    - Added method getContextPath(). This is a natural complement to
      method getContextURI()
    - I based my implementation of LinkTool on the implementation
      contributed by Nathan. I changed the following aspects:
      - Added support to work with relative URIs (in addition to 
        absolute URIs)
      - Added support to work with URIs that point to other servers
      - Added support to resolve Struts action names to URI references
      - Added support to resolve Struts forwards to URI references
    
- ErrorsTool:
    - Added method public boolean exist(String property). This is a 
      natural complement to public boolean exist().
    - Changed methods get() and getAll() to return ArrayLists instead
      of HashMaps. With ArrayList the sequence of error messages is
      maintained. This was not the case before.
    - Introduced methods getMsgs() and getMsgs(String property). These
      two methods generate the necessary markup to display error messages
      in the view. All the markup is configurable in the message resources.
      We discussed previouly to skip these methods and instead recommend
      the use of a macro to render error messages. 
      While creating some examples for the documentation I realized that 
      it is very painful to have to write a macro each time you 
      want to render some error messages. Displaying error messages is 
      such a basic and frequently needed feature that I feel we need to 
      provide basic support for it in the ErrorsTool. It is still 
      possible to use macros to custom format error messages.

- FormTool:
    - Added method getTokenName() to retrieve the request parameter name 
      that must be used for the transaction token. This is necessary to 
      be able to handle the transaction token.

- ActionMessages:
    - Not implmented yet. This is a feature of the upcoming Struts 1.1 
      release. I need to study this in more detail to really understand 
      what the intended behavior is in relation to the ErrorMessages

--------------------------------------------------------------------


--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to