Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Event handling

 
Andrew Collins
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rangers,
All my actions extend from following ExceptionHandledAction :

My actions implement the abstract processAction method.
Doing so, I never have to worry about catching exceptions. ExceptionHandledAction will take care of this.
Now, I wrote a DoubleClickTable that fires a DoubleClickEvent to DoubleClickListeners in case a user doubleclicks a tablerow in order to book a seat.
DoubleClickEvent extends EventObject and DoubleClickListener implements EventListener.
Since DoubleClickListener is not an Action I cannot fit my DoubleClick in the ExceptionHandled framework, so here I still have to deal with exception handling.
I'm trying to refactor things so that even my doubleClick event gets handled by the ExceptionHandled framework but I don't get it done.
Can any of you give me advice ?
Thanks.
 
Eduard Jodas
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can see two workarounds:
* You can have a DoubleClickListener whose only purpose would be to translate DoubleClickEvents into ActionEvents and call your desired Action.
* I suppose your DoubleClickListener interface just have one method like
doubleClicked(DoubleClickEvent anEvent)
you could delete you DoubleClickListener and DoubleClickEvent classes and make you DoubleClickTable accept ActionListeners
addDoubleClickListener(ActionListener aCL)
This doesn't conforms with the JavaBeans naming convention but I don't find it important.

One more think: in your ExceptionHandledAction I would catch Throwable instead of Exception, just in case ...
 
Andrew Collins
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Eduard,
In the mean time I implemented your first workaround myself. It feels good to see that someone else comes up with exact the same solution.
BTW, thanks for the Throwable advice.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic