You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Ugo Cei <u....@cbim.it> on 2005/05/16 15:53:53 UTC
[CForms] Field definitions aren't contextualizable
In trying to implement a CAPTCHA validator for CForms, I found out that
I needed to to store an attribute in the session from a field definition
builder and I discovered that even if my class extending
AbstractDatatypeWidgetDefinitionBuilder implemented Contextualizable,
its contextualize method was never called.
After a little debugging, I discovered that the DefaultFormManager
instantiates a SimpleComponentSelector directly but does not
contextualize it. So, the SimpleComponentSelector cannot contextualize
the widget builders that it creates in turn.
OK, to make it short, I locally did a quick fix (against 2.1.8-dev):
Index: src/blocks/forms/java/org/apache/cocoon/forms/DefaultFormManager.java
===================================================================
---
src/blocks/forms/java/org/apache/cocoon/forms/DefaultFormManager.java
(revision 170351)
+++
src/blocks/forms/java/org/apache/cocoon/forms/DefaultFormManager.java
(working copy)
@@ -104,6 +104,7 @@
manager.release(service);
}
});
+ widgetDefinitionBuilderSelector.contextualize(avalonContext);
widgetDefinitionBuilderSelector.configure(configuration.getChild("widgets"));
}
I'm not sure this is the right thing to do. Would someone who is more
knowledgeable of CForms internals please review this, so that I can
apply it?
Thanks a lot,
Ugo
Re: [CForms] Field definitions aren't contextualizable
Posted by Sylvain Wallez <sy...@apache.org>.
Ugo Cei wrote:
> In trying to implement a CAPTCHA validator for CForms, I found out
> that I needed to to store an attribute in the session from a field
> definition builder and I discovered that even if my class extending
> AbstractDatatypeWidgetDefinitionBuilder implemented Contextualizable,
> its contextualize method was never called.
>
> After a little debugging, I discovered that the DefaultFormManager
> instantiates a SimpleComponentSelector directly but does not
> contextualize it. So, the SimpleComponentSelector cannot contextualize
> the widget builders that it creates in turn.
>
> OK, to make it short, I locally did a quick fix (against 2.1.8-dev):
>
> Index:
> src/blocks/forms/java/org/apache/cocoon/forms/DefaultFormManager.java
> ===================================================================
> ---
> src/blocks/forms/java/org/apache/cocoon/forms/DefaultFormManager.java
> (revision 170351)
> +++
> src/blocks/forms/java/org/apache/cocoon/forms/DefaultFormManager.java
> (working copy)
> @@ -104,6 +104,7 @@
> manager.release(service);
> }
> });
> + widgetDefinitionBuilderSelector.contextualize(avalonContext);
>
> widgetDefinitionBuilderSelector.configure(configuration.getChild("widgets"));
>
> }
>
> I'm not sure this is the right thing to do. Would someone who is more
> knowledgeable of CForms internals please review this, so that I can
> apply it?
Looks ok, except that contextualize() comes before service() in the
Avalon lifecycle.
Sylvain
--
Sylvain Wallez Anyware Technologies
http://apache.org/~sylvain http://anyware-tech.com
Apache Software Foundation Member Research & Technology Director