At 02:41 PM 5/17/99 -0700, you wrote:
>Another approach is to give an exemplar of one table row with
>substitution parameters inside a looping construct of some kind. Then
>the HTML stays strictly on the client side.
>
>Rod McChesney, Korobra
That's actually pretty much what we do. We have a template engine that we
came up with, before webmacro and co. were announced. All of our HTML
markups are HTML comments so that we don't have to do any tricks with HTML
editors to keep them from complaining about invalid HTML. Here's a real
example of some of our HTML template code:
<TABLE>
<!--#parse block=begin-->
<TR>
<TD ALIGN="LEFT"><FONT SIZE="-1" COLOR="#FF0000" FACE="Arial">Closed
Group.</FONT> </TD>
<TD><FONT FACE="Arial"><B>
<!--#parse block_token=group_name-->
</B></FONT></TD>
</TR>
<!--#parse block=end-->
</TABLE>
It looks just like normal HTML in an HTML editor as long as your editor
doesn't display the comments. All of our markups begin with <!--#parse and
end with --> so our parser can find them. A block is just a simple loop and
repeats however many data elements block_token contains (you can have more
than one block_token), in this case for how many group_name data elements
there are. This way the HTML guys either build a table with dummy data in
it and the servlet guys turn it into templates (this is easier than it
sounds with a good HTML editor) or if the HTML guy knows the templates well
enough, they convert it for us. We have Java packages that the servlet
people use to load the data structures and parse the HTML, so the nasty
parsing work is hidden from them. There are also methods for single data
values and a couple of other common things.
This is way a simpler and more primitive approach than something like
Webmacro, which seems pretty neat but does way more than what we need.
I think hard coding HTML in a servlet is bad unless it is for a very simple
project. Of course absolute statements are also bad and this is all just my
opinion anyway...
Lloyd
>George Svedloff wrote:
>>
>> I quite agree - the proliferatoin of proprietary solutions is a little
>> annoying.
>>
>> In my opinion, tempaltes offer a very clean solution. They have one
>> problem - it is hard to deal with dynamic elements like talbes or lists
>> when you use templates.
>>
>> The solution we are currently trying for this is the following:
>>
>> Use tempaltes, and when you need to use a dynamic element like table,
>> insert some "placeholeder" into your HTML instead of the table that will be
>> substituted later. Then use something to dynamically generate the table
>> (we currently use the W3C DOM library). After the table is generated,
>> replace the "placeholeder" with the generated table.
>>
>> Any comments on this approach?
>>
>> George Svedloff
>> Informix Software, Inc.
___________________________________________________________________________
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