you can try this, but i think you will find it won't work for border/body because borders are not ordinary components. rendering of a container with a border component in it cannot be straightforward because encountering the border tag causes recursive context switches between markup streams. that's why it's special and that's why container has to know about it. you can't render a container by simply rendering its markup stream and attached components because rendering a border tag changes the rendering process itself!
Juergen Donnerstag wrote:
May be I have a solution to the [body} and [autolink] problem of having Border related code in Container autolink related code in MarkupParser and ComponentTag.
The idea is around what I called a ComponentNameResolver. It is a simple interface with just one mehtod: handleUnknownComponentName(...). ComponentNameResolver is may be a little bit misleading, as it not only does the mapping of componentName to Component. handleUnknownComponentName() is also responsible to call render() on that component. That was necessary to support [body].
Lets start with [body]. Container.renderNext() frst tries to find a Component within the component hierachie with the componentName (let us ignore autolink for a moment). If not foud, it'll test for [body] and if its not, than throw an exception. I introduced a protected methd called Container.handleUnknownComponentName() which default implementation simply return false. Border (or any other Container) may subclass it and provide its own implmenentation. I just copied the [body] code from Container into Boder.handleUnknownComponentName(). ready.
It was obviuos to cover [autolink} the same way. There was only one problem: Autolink is not a component. I solved it by adding a List of ComponentNameResolvers to AppSettings. This way anybody may add his own (static) Resolvers. Container.renderNext() iterates through this list prior to throwing an excpetion (the exception will only be thrown if no Resolver is able to handle the componentName).
Container.renderNext() now look like below. No more [body], no more autolink related code. I remove the autolink code from MarkupParser and ComponentTag and moved it into an AutolinkComponentNameResolver. I run all examples and the test available. It really seems to work.
The order of execution is 1) try to find a Component with componentName 2) try all static ComponentNameResolvers from AppSettings 3) try the Container's (or any subclass) .handleUnknownComponentName()
What do think?
Juergen
..... // Get the component for the component name from the given container Component component = get(componentName);
// Failed to find it?
if (component != null)
{
component.render(cycle);
}
else {
final List componentNameResolvers =
this.getApplicationSettings().getComponentNameResolvers();
final Iterator iter = componentNameResolvers.iterator();
while (iter.hasNext())
{
final ComponentNameResolver resolver =
(ComponentNameResolver) iter.next();
if (resolver.handleUnknownComponentName(cycle,
markupStream, tag, this) == true)
{
return;
}
}
if (handleUnknownComponentName(cycle, markupStream, tag) == false)
{
markupStream.throwMarkupException("Unable to find
component named '" + componentName + "' in " + this);
}
}
------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ Wicket-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-develop
------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ Wicket-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-develop
