You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Erik Hatcher <er...@ehatchersolutions.com> on 2004/08/02 01:39:01 UTC
TAsPectJ
At OSCON (O'Reilly Open Source Convention) this past week, I had the
pleasure of attending Raminvas Laddad's excellent AspectJ tutorial.
While I've kept in the loop of what AOP is all about, I had not
actually tried it (other than pseudo XDoclet, WebWork2, and dynamic
proxy types of things), I'm a bit ashamed to report.
During my travel to OSCON, I finally started reading Raminvas' AspectJ
in Action book, and have only made it through the first section
explaining the concepts and syntax.
The night before the tutorial I downloaded AspectJ and tried a simple
HelloWorld kinda thing to make sure I had the necessary pieces to
leverage the goodies I'd learn in the tutorial. Half-way through his 3
hour session, I had enough infrastructure in place to aspect the demo
Tapestry application I use for my presentations. The one feature that
has bothered me about Tapestry is its difference with what happens when
validation fails compared to Struts. When validation fails, the
listener method is still called in Tapestry, and this requires a bit of
code to handle it *in every single listener method*. While I'm still
on the fence on whether Tapestry should itself avoid calling a form
listener method when validation fails, in the apps I build it is always
the case. AspectJ came to my rescue. I created this aspect...
public aspect ValidationAspect {
void around(BasePage page) : execution(void
Home+.listener(IRequestCycle)) && this(page) {
ValidationDelegate delegate = (ValidationDelegate)
page.getBeans().getBean("delegate");
System.out.println("aspected: " + delegate);
if (!delegate.getHasErrors()) {
proceed(page);
}
}
}
Disclaimer: Home+.listener is specific to my code - I need to tinker
with the point cut definition to make it more general purpose - so if
you borrow this idea, you'll need to change that part at least. Using
a cflow or cflowbelow is probably the next refactoring I'll try to key
off the call chain through @Form for invoking a listener method, but
that won't catch @Submit listeners (which I personally avoid anyway).
Voila - I now keep my form listener methods devoid of the validation
concern (unless of course there is programmatic validation needed as
well, but this is far less common in my apps than straightforward field
validation).
I really wish Tapestry had an intermediate hook between a form
submission and the invocation of the listener method built-in, though
(and geez, you'd think Page*Validate*Listener is the right hook, but
it's not). AspectJ really solved the issue I have been frustrated
with, so I'm now smiling! In fact, being able to pull this trick off
after only brief exposure to AspectJ has left me grinning all week and
is a great case in point regarding the power and ease of use of AOP in
general.
Erik
p.s. Immediately following the AspectJ tutorial, I gave my Tapestry
tutorial to a sold-out crowd, and mentioned my AOP success that
morning. Many folks lingered after my presentation, and I was able to
show off my success to them.
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Tapestry on CD/Offline
Posted by Cyril Godefroy <cy...@ecomposite.fr>.
Makes sense. A typical solution might be:
Jetty as the web app container
Hsqldb as the database (in memory version)
but then, you might even use struts or jsf. Tapestry won't bring you
anything special in that regard ( it does already for many other
aspects).
Cyril
On Aug 2, 2004, at 3:27 PM, tibolists wrote:
> then launching the Tapestry app, include launching a embedded web
> application server.
>
> Is that make sense ?
Re: Tapestry on CD/Offline
Posted by tibolists <ti...@free.fr>.
What I wanna mean by "Offline",
is: not connected to the net.
Well, in fact, the goal, is to have a tapestry app, work as a standalone
program.
even if the user's computer do not have a webserver and anything else
the OS installed on it.
then launching the Tapestry app, include launching a embedded web
application server.
Is that make sense ?
On Mon, 2004-08-02 at 13:47, Erik Hatcher wrote:
> What do you mean by "offline"? You need a web container.... so at the
> minimum you need something like Jetty and a way to launch it. I'm sure
> you could wrap it all into a single launchable JAR file that can be
> double-clicked and even open up the default browser. ZOE (zoe.nu) does
> this type of thing.
>
> Erik
>
> On Aug 2, 2004, at 7:49 AM, tibolists wrote:
>
> > HI,
> >
> > Is there any way to have a fully tapestry app, work on CD,
> > or even work offline from harddisk ?
> >
> > tibo
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Tapestry on CD/Offline
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
What do you mean by "offline"? You need a web container.... so at the
minimum you need something like Jetty and a way to launch it. I'm sure
you could wrap it all into a single launchable JAR file that can be
double-clicked and even open up the default browser. ZOE (zoe.nu) does
this type of thing.
Erik
On Aug 2, 2004, at 7:49 AM, tibolists wrote:
> HI,
>
> Is there any way to have a fully tapestry app, work on CD,
> or even work offline from harddisk ?
>
> tibo
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Tapestry on CD/Offline
Posted by tibolists <ti...@free.fr>.
HI,
Is there any way to have a fully tapestry app, work on CD,
or even work offline from harddisk ?
tibo
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org