I've continued to give thought to how we could bridge
the gap between Tapestry and JSPs.
It would be nice(*) if you could use a JSP, instead of
an HTML template, for your page.
You could then mix Tapestry components, JSP tags or even
(ugh!) Java scriptlets together.
(*) If you consider a bastardization of everything I
hold dear, "nice". But it is expedient.
A special Tapestry taglib would allow you to use
Tapestry components in the JSP. Something like:
<tapestry:component id="form">
<tapestry:component id="inputName"/>
<tapestry:component id="inputAddress"/>
<input type="Submit" value="Register">
</tapestry:component>
As with real Tapestry, a page specification would
provide the details.
Unfortunately, without tearing Tapestry apart (in a way
that would break everything), I don't know if this is
possible.
Here's the basic problem: A complete incompatibility
between the Tapestry rendering model, and the JSP/tag
rendering model.
In Tapestry, a component has a single method,
renderComponent() that renders the entire component:
public void renderComponent(...)
{
// ... render open tag and attributes
renderBody();
// ... close tag
}
JSPs would break this into *three* pieces:
public void doStartTag(...)
{
// render open tag
}
public void doEndTag(...)
{
// render close tag
}
JSP takes care of rendering the body portion for you,
though you can get a little control back (you can have
it render the body into a container, and then decide
what to do with that content).
So far, this is looking pretty insurmountable. I could
hack something together that would allow the use of
components that *dont* allow a body (Insert, for
example), but those aren't interesting or useful.
I have a glimmer of an idea about how to bridge this
gap, but its frail and tricky.
First, we have a magic version of IMarkupWriter that is
super-smart.
Instead of invoking
renderBody(writer, cycle)
You invoke
writer.renderBody(this);
doStartTag() invokes prepareForRender(), then invokes
render().
The magic IMarkupWriter stores all the operations
invoked on it. Maybe dynamic proxies?
doStartTag uses the magic writer to emit all the output
up until renderBody() was invoked, and returns.
JSP takes over and renders the body.
JSP invokes doEndTag(). Our tag now uses the magic
writer to perform all the operations that occured after
renderBody() was invoked. It then invokes
cleanupAfterRender() on the component.
OK ... that's just a guess. It would require that the
renderComponent() method just do pure rendering; any
special interaction with the IRequestCycle (such as
registering and deregistering an instance, the way Body
and Form do) would have to take place in prepareForRender
() and cleanupAfterRender().
Dealing with nested markup writers would also be very,
very tricky. To be honest, my brain is spinning just
thinking about this stuff.
Can it be done? Possibly. Maintaining backwards
compatibility? Possibly, but less likely.
--
[EMAIL PROTECTED]
http://tapestry.sf.net
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Tapestry-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer