Re: Why not make listener events more generic
Drew Davidson <[email protected]>
| Newsgroups | gmane.comp.java.tapestry.devel |
|---|---|
| Message-ID | <[email protected]> |
Geoff Longman wrote:
>Right now expressions that invoke listeners are like this:
>
>listeners.doSomething
>
>where doSomething is a method with the correct signature:
>
>public void doSomething(IRequestCycle cycle) throws RequestCycleException
>
>Why not extend this to make it possible to implement simple listeners
>directly in OGNL?
>i.e. make the expression the listener. I'm finding that I'm building pages
>using aggregation with beans
>more than extending a Page class these days. Would cut down on the code
>writing if I were able
>to manipulate my beans without declaring the listener methods.
>
>One could extend the OGNL context to contain the cycle as well as the
>component. This would
>allow one to replace the method declaration with simple expressions like:
>
>cycle.setPage("Home")
>beans.myBean.incrementCounter()
>
>etc.
>
>Any thoughts?
>
>
Instead of having an event like "doSomething(IRequestCycle cycle)"
implemented on an object why not have a generic one that will forward to
an OGNL lambda expression? This would allow you to not have to code up
an entire class to implement a listener for simple cases like described
above. An OGNL lambda expression is an expression that is compiled to
an AST that can then be executed at a later time.
Example:
#myExpression = :[ doSomething() ]
#myExpression(newRootObject)
Will cause doSomething to be called on newRootObject. The calling
syntax is NOT parameters; only one is allowed and it becomes the root
object for the called expression.
- Drew
--
+---------------------------------+
< Drew Davidson | OGNL Technology >
+---------------------------------+
| Email: [email protected] /
| Web: http://www.ognl.org /
| Vox: (520) 531-1966 <
| Fax: (520) 531-1965 \
| Mobile: (520) 405-2967 \
+---------------------------------+
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf