tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Enrique Zamudio <ezamu...@mac.com>
Subject Switch Component
Date Sat, 12 Jun 2004 03:24:56 GMT
I was looking for a Switch component, similar to the WOSwitchComponent in
WebObjects.

I couldn't find anything, so I wrote my own. But to make it work, I needed
to change a couple of things, basically two lines in BaseComponent.java, in
the readTemplateMethod:

the first line,

IPageSource pageSource=loader.getEngine().getPageSource();

changed to

IPageSource pageSource = cycle.getEngine().getPageSource();

and then the line

ITemplateSource source = loader.getEngine().getTemplateSource();

changed to

ITemplateSource source = cycle.getEngine().getTemplateSource();

This is because the Switch component needs to call PageLoader's
createImplicitComponent method, but the loader's getEngine() method only
returns an object when it's inside the loagPage() method. So it wasn't
working, but this fixed it.

I'm attaching the source file for the Switch component, so that you can
review it, use it if you want to (remember you first need to change those
two lines) and even integrate it into Tapestry. I was kind of surprised that
a componente like this isn't already a part of the framework, since it makes
it much more powerful.

The only thing that I don't like much for now is that I need to pass the
location of the template inside the classpath for the Switch to work. Maybe
someone can help me make this work without the need to specify the location
of the template file?

Cheers,
eZL

-- 
"Today, reliance on broadcasting is the very definition of a technologically
backward society "
    William Gibson



Mime
View raw message