On Tue, 25 May 1999, Robert A. Crawford wrote:
....
> >      - output diverting...
>
>         I'm not sure what you mean. All of the template packages
> I've seen use java.io.Writer or some subclass as their interface.
> You can manipulate that as you need.
>


This kind of functionality would make "template" idea worth its
name...
Before details should mention that I've seen first this concept
in Ralph Engelshall's (http://www.engelschall.com)
"Website Meta Language"  tool - a powerfull web-site generator.

"Output diverting" allows a designer to better distinguish betwen
"layout" and "content".

Consider for example that you are calling getMethods() within template
to display data and some of them result in exceptions, and want to display
error messages in top of the same page, to allow users to see what's
is wrong.

Or that within an included file some designer makes a common table layout
with "cells" and in another file(s)
(that includes the "layout" template) tell in wich "cell" what to
write.

Some examples of the concept:
------------------
You have somewhere within a "GenericLayout.html" file:
<UL>
 <WriteHere ID=LeftSideMenu>
</UL>
.......
and at the bottom of the same file:
........
<CENTER>
<TABLE>
<WriteHere ID=HorizontalTextMenu>
</TABLE>
</CENTER>
.......

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

And in all other templates that include the same "DefaultLayout.html"
we can "fill" with items in both  left-side and horizontal menus,
with optins depending on each page:


$for $menuItem in $menuList   {

 <WriteThere ID=LeftSideMenu >
   <LI><A HREF=$menuItem.Href>
       <IMG SRC="$menuItem.IconUrl"
        ALT="$menuItem.LongDescription">...
       </A>
  </LI>
 </WriteThere>

 <WriteThere ID=HorizontalTextMenu >
   <TD><A HREF="$menuItem.Href">
          $menuItem.ShortDescription
       </A>
   </TD>
 </WriteThere>

}

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

Other usage would be to print error messages elsewhere (even before!!)
than the place in template where the error condition is tested/observed:


<UL>
  <WriteHere Id=Errors>
</UL>

.....

$if $error.Condition {
  <WriteThere Id=Errors>
     <LI> Please enter a valid date using "MM/DD/YYYY" format! </LI>
  </WriteThere>
}

...
$if $anotherError.occured {
  ... write this one too "there", where errors should be listed ...
}



----------------------------------
As an answer at the original question wich was
"why using templates instead of JSP" is that some template engines
might have some powerfull capabilities (easier to use and understand
by non .java programmers)
that would be less or more difficult to replicate both with .jsp files or
native Java code.

Or might not.

Each developer or html-based interface designer will find both features
and limitations in each approach - .jsp, servlet's println(..),
API-based content generators, or template engines available,
and from diversity of options and tools, until all concepts are
reviewed/tested/clarified will hopefully benefit us all.

(sorry if it sounds religious again)

Cezar.

___________________________________________________________________________
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

Reply via email to