cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Gianni <>
Subject Re: Adding a ProcessingPhaseListener to a form?
Date Thu, 18 May 2006 14:37:21 GMT
Hi Carsten,
if you use a java listener (in all cocoon forms, not just for
ProcessingPhaseListener) the class
o.a.c.forms.event.impl.JavaClassWidgetListenerBuilder is responsible for
setting it up. If calls a LyfecycleHelper..setupComponent(listener,
null, null, manager, null);

AFAIK, since only the instance and the manager are passed in, i suppose
that if you implement Configurable in your java class you will not
obtain a valid Configuration object.

It should not be difficult (since the w3c Element is available) to pass
is wrapped in a Configuration to the LifecycleHelper ... trying right now.

Ok, in JavaClassWidgetBuilder is should be enought to add the
Configuration conf = ConfigurationUtil.toConfiguration(element); line
and then pass it to the LifecycleHelper.

Line 54 :
        Object listener = ClassUtils.newInstance(name);
        if (listenerClass.isAssignableFrom(listener.getClass())) {
            Configuration conf = ConfigurationUtil.toConfiguration(element);
            LifecycleHelper.setupComponent(listener, null, null,
manager, conf);
            return (WidgetListener)listener;

Don't have time right now to test and eventually commit this, but it's
worth doing it : it will enable every java listener to implement the
Configurable interface and receive configuration from the definition.
Will have time to do this this evening, unless you do it before me :)


Carsten Ziegeler wrote:

>Simone Gianni schrieb:
>>Hi Carsten,
>>i committed a patch to make it possible to add it from the definition.
>>See . It's already
>>committed in 2.1.X (and so in trunk too). Documentation on daisy has
>>been updated, see
>>. Also the form1 example has been updated, see
>>src/blocks/forms/samples/forms/form1.xml line 25.
>Wow, thanks Simone. Great, one question: is it possible to pass in a
>configuration into the event listener instance?
>For example:
>  <java class="myclass">
>     </some config>
>  </java>
Simone Gianni

View raw message