cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylv...@apache.org>
Subject Re: svn commit: r292158 [4/4] - in /cocoon: blocks/ajax/ blocks/ajax/trunk/ blocks/ajax/trunk/WEB-INF/ blocks/ajax/trunk/WEB-INF/xconf/ blocks/ajax/trunk/java/ blocks/ajax/trunk/java/org/ blocks/ajax/trunk/java/org/apache/ blocks/ajax/trunk/java/org/apache...
Date Wed, 28 Sep 2005 12:48:53 GMT
Torsten Curdt wrote:

>> +    /**
>> +     * The attributes of this continuation
>> +     */
>> +    private Map attributes;
>
>
> Mate, what are these attributes to a continuation for?


See this:

>Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js
>URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js?rev=292158&r1=292157&r2=292158&view=diff
>==============================================================================
>--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js (original)
>+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js Wed
Sep 28 03:24:51 2005
>@@ -118,6 +118,9 @@
> 
>     var comingBack = false;
>     var bookmark = cocoon.createWebContinuation(ttl);
>+    
>+    // Attach the form to the continuation so that we can access by just knowing the
continuation id
>+    bookmark.setAttribute("form", this.form);
> 
>     if (comingBack) {
>         // We come back to the bookmark: process the form
>  
>

and this:

>Added: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/SuggestionListGenerator.java
>
<snip/>

>+        // The interpreter id is the sitemap's URI
>+        String interpreterId = SitemapParameters.getLocation(parameters).getURI();
>+        wk = this.contManager.lookupWebContinuation(continuationId, interpreterId);
>+        if (wk == null || wk.disposed()) {
>+            throw new InvalidContinuationException("Cannot get continuation for suggestion
list");
>+        }
>+        
>+        Form form = (Form)wk.getAttribute("form");
>+        if (form == null) {
>+            throw new ProcessingException("No form is attached to the continuation");
>+        }
>+        
>+        this.locale = form.getLocale();
>+        
>+        Field field = (Field)form.lookupWidget(widgetPath);
>+        list = field.getSuggestionList();
>+        if (list == null) {
>+            throw new ProcessingException(field + " has no suggestion list");
>+        }
>  
>

The selection list generator, which is called through an Ajax request, 
needs to access data in the form that is currently displayed. And this 
form is held by the continuation.

Since we don't want to _call_ the continuation but just access some 
attached data, the quick'n dirty solution was to use the knowledge that 
WebContinuation.getUserObject() returns a FOM_WebContinuation and from 
there use Rhino methods to access the "form" property.

That seemed bad to me, strongly coupling the SelectionListGenerator to 
the flow implementation. I guess Mr JavaFlow will agree on this ;-)

Then I considered that a continuation is actually an application scope, 
just as Context, Session and Request are. The lifetime and visibility of 
a continuation is in-between Request and Session. And other scopes do 
have attributes that we use to pass data around, whereas a continuation 
did not. That's why I added attributes to Continuation.

We can then attach some data to a continuation without being tied to the 
actual flow implementation.

Sylvain

-- 
Sylvain Wallez                        Anyware Technologies
http://people.apache.org/~sylvain     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


Mime
View raw message