The Artima Developer Community
Sponsored Link

Java Buzz Forum
Erik Hatcher having fun with: TAsPectJ (Tapestry + AspectJ)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
Erik Hatcher having fun with: TAsPectJ (Tapestry + AspectJ) Posted: Aug 2, 2004 11:37 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: Erik Hatcher having fun with: TAsPectJ (Tapestry + AspectJ)
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement
Erik Hatcher finally had some time to grok AOP and AspectJ. He got quickly up to speed (as he normally does) and saw a use for it right away. 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); } } } That piece of code looks for anything that implements Home base class / interface (Home+). It would be nice to make this generic for anyone using Tapestry as Erik has said, so that it would only be called on org.apache.tapestry.form.Form listeners (via a cflow()). Nicely done Erik :)

Read: Erik Hatcher having fun with: TAsPectJ (Tapestry + AspectJ)

Topic: Slightly Prettier DocBook Reference Pages Previous Topic   Next Topic Topic: There Ought to be a Law

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use