[EMAIL PROTECTED] wrote:

> A question I have... is it feasible at all to use Velocity as the
> presentation mechanism with a Struts MVC framework?
>

The simple answer is "of course".  The <forward> mechanism can easily
forward to a servlet that displays the appropriate Velocity template, or
your Actions can do so directly if they want to.

However, you will want to research (at least) the following issues:

* Velocity runs off of a "context" object to make things visible
  to the template.  How does it deal with objects in all three
  relevant scopes (request, session, and application -- page scope
  is relevant only in a JSP environment)?

* You would need to establish conventions for how to decide which
  template(s) should be selected for display, and what sets of
  attributes get exposed to them.

* If you utilize the internationalization support of tags like
  <bean:message>, you will need to figure out an alternative
  strategy.

* There is a synergy between the way that the form-based tags in
  Struts work together with the form bean auto-population of
  properties that you would give up, although I imagine there
  are workarounds to that.

* I haven't looked real deeply, but does Velocity have an easy way to
  redisplay the current values of input fields like the Struts custom
  tags do?  If not, and if this is important to your app, you will
  want to determine how to work around it.

* There are lots of other conveniences (automatic URL encoding of
  hyperlinks, automatic filtering of HTML-sensitive characters, and
  so on) that the Struts tags do for you that you will need to work
  around if you utilize them.

* Scriptlets and scriptlet expressions are not allowed in a Velocity
  template -- if you need to do something not supported by the
  Velocity language you will have to accomplish it some other way.

* Beyond scriptlets, you gain the ability to perform the unique
  features of a Velocity template, and give up the ability to use
  all the unique features of JSP pages -- including giving up on the
  ability to utilize the smarter tags of future versions of Struts
  (for example, optional generation of client side JavaScript for
  field validation), or any other JSP custom tag library that
  is available.

>
> Regards,
> James W.
>

Craig McClanahan

Reply via email to