cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Gianni <s.gia...@thebug.it>
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 :)

Simone


Carsten Ziegeler wrote:

>Simone Gianni schrieb:
>  
>
>>Hi Carsten,
>>i committed a patch to make it possible to add it from the definition.
>>See http://issues.apache.org/jira/browse/COCOON-1781 . It's already
>>committed in 2.1.X (and so in trunk too). Documentation on daisy has
>>been updated, see
>>http://cocoon.zones.apache.org/daisy/documentation/864/forms/concepts/479.html
>>. 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:
><fd:on-processing-phase>
>  <java class="myclass">
>     </some config>
>  </java>
></fd:on-processing-phase>
>
>Carsten
>  
>
-- 
Simone Gianni

Mime
View raw message