Quoting Tim Panton - Westhawk Ltd ([EMAIL PROTECTED]):
> We've used Jsp and webmacro, and
> they both have their strong points,
> but they both impose a certain
> design and process on a project,
> of the 2 I prefer WM since the
> process puts the java architect in
> control, as opposed to Jsp where
> the html'ers can stick any damn
> java they like into the page and
> blow away my business logic!
WebMacro actually allows you to put the template author in control
without letting them blow away your business logic. A less well
known interface in WebMacro is the ContextTool API:
public interface ContextTool {
Object init(Context c)
}
You can implement this to create "magic" variables on a web page.
For example, you might have back end searching logic. A template
author should be able to drop this searching logic on any template
at all, and not require progammer help to make it go, just doing
this:
#foreach $result in $Search.Results { ... $result.Name ... }
should be enough to automatically invoke the Search logic. In
WebMacro you accomplish this by writing a SearchTool that
implements the ContextTool interface.
Object init(Context c) { return new Search( Context.get(...) ); }
The Context represents the current request and contains things like
the HttpServletRequest object so you could build your Search object
based on a query string submitted by the user, or some such.
The advantage of this approach is that engineering can create useful
generic tools like $Search and $News and then the page designers can
assume total responsibility for the flow between the pages and what
data appears on which page.
And, all the while, they can't blow away your business logic because
they still can't write Java code in their templates.
> In the third case we have some
> legacy data available as XML, our
> servlet just writes the appropriate
> subtree.
XML is an excellent solution. I don't think it's well suited to all
pages, but I do think that a certain class of data is best rendered
through some kind of XML/XSL solution.
A very interesting technique is to combine the XSL worldview with
the template worldview. Imagine plugging in a new directive so that
in a WebMacro template you could switch modes and do:
#xsl $myXml using "my.xsl"
You would have to write this directive but it would be easy, and many
people already have (perhaps you can borrow some code). The idea would
be that $myXml resolves to some XML object, which can be rendered by
feeding it through the my.xsl. The output of that process would get
dropped into the WebMacro template at this point.
You would then be able to use generic templating techniques to generate
most of the page (which can be tricky with XSL sometimes) and then
switch to XSL to render a news article or other well defined but
free flowing structure.
Food for thought.
Justin
[EMAIL PROTECTED]
AltaVista Company
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html