cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylvain.wal...@anyware-tech.com>
Subject Re: [VOTE] Add parameter to Woody {SelectionList,Widget}.generateSaxFragment
Date Tue, 21 Oct 2003 10:57:32 GMT
Ugo Cei wrote:

> Sylvain Wallez wrote:
>
>> Can you explain in more details what's the purpose of the 
>> jxpathContext here and where its value come from? Adding a dependency 
>> on JXPath so high in Woody interfaces doesn't seem good to me.
>
>
> The value comes from WoodyTemplateTransformer:
>
>         Object flowContext = FlowHelper.getContextObject(objectModel);
>         WebContinuation wk = FlowHelper.getWebContinuation(objectModel);
>         JXPathContext jxpc = JXPathContext.newContext(flowContext);
>
> (similar code must be added to WoodyGenerator also).
>
> We need this if we want to populate selection lists with collections 
> defined in the flowscript and avoid the need to call a different 
> pipeline. Please have a look at the following (contrived) sample, 
> while I try to prepare a more meaningful one:
>
> <wd:selection-list model="model" key="key" value="value"/>
>
> ...
>
> public class MyBean {
>   public int getKey() { ... }
>   public String getValue() { ... }
> };
>
> ...
>
> var list = [ new MyBean(1, 'One'), new MyBean(2, 'Two') ];
> form.showForm("uri", { "model" : list });
>
>
> Now that I think about it, we might as well pass "Object flowContext" 
> to generateSaxFragment, thus avoiding a dependency on JXPath. So, I'm 
> changing my proposal to the following:
>
> Change the signature of two interface methods:
>
> org.apache.cocoon.woody.formmodel.Widget.generateSaxFragment
> org.apache.cocoon.woody.datatype.SelectionList.generateSaxFragment
>
> by adding a third parameter:
>
> void generateSaxFragment(ContentHandler contentHandler, Locale locale, 
> Object flowContext)
>
> Hope this answers your doubts.


Ok, I understand. I encountered a somehow similar problem and came to 
the conclusion that what we need is actually to have <wd:selection-list> 
a pluggable component.

We could then have <wd:selection-list 
type="default|flow-jxpath|javascript|whatever"> and the attributes and 
content of this element be the configuration of the selection list. We 
can then have the FlowJXPathSelectionListBuilder be Contextualizable to 
give the Avalon Context to the FlowJXPathSelectionList it creates.

The flow context is then available through 
FlowHelper.getContextObject(ContextHelper.getObjectModel(avalonContext)).

This would avoid passing along the context object and also use it in 
situations other than generateSAXFragment() such as during form 
validation (for closed enumerations).

What do you think?

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com



Mime
View raw message