Zat Home
Support | Bug Report

469

No way to create HTML tag on the fly and insert it into a document

This is one we should talk about, so we design it right.
The bug is that currently, there is no way to create an HTML
tag on the fly and insert it into a document. If you insert
a string into an HTML text bean that contains an "<", it is
always converted into "<". The fix for this would be to
add a property that turns this behavior off, but I think we
can do better.

Here's my ideas off the top of my head:

Remove the "Preformatted" property from the HTML text bean.
Turn it into a separate bean that outputs <PRE>, then its
children, then </PRE>

The HTML text bean *always* turns < into < and so forth
(I'm not sure about this).

Introduce a new bean that can be used to create HTML on the
fly (I'd call it dynamic html, if that weren't already taken).
You can set its content, and that content is printed out
without converting anything. For now, let's call it the
"raw HTML" bean. This bean should have methods for setting
the content, and appending new content.

Finally, add a new method to all HTML beans that is like
the print method, but prints to a string. You can use this
to set the value of the raw HTML bean.

This problem came up when I was trying to convert a sequence
of text strings that are returned from a database into a
sequence of links. There was no way to create a anchor
tag on the fly, and I don't know beforehand how many numbers
I am going to get back. The only way to do this would be
to store everything into a vector, and then use an HTML
repeater. Instead, want to create a snippit of HTML code that
contains an anchor. I then print that snippet to a string,
and append the string to a "raw HTML" bean. This is for
the bugcounter example that Philip wrote.

** Wm 5/27/99 **

Added RawHTML bean for, and methods to set and get the HTML content.

** Philip 6/28/99 **

RawHTML bean works
** Brian 00.03.13 **

Generated on: Mon Apr 10 11:49:39 PDT 2000