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

Reply via email to