cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Klimetschek (JIRA)" <j...@apache.org>
Subject [jira] Commented: (COCOON-1963) Add a redirect action to the browser update handler
Date Thu, 12 Apr 2007 12:33:32 GMT

    [ https://issues.apache.org/jira/browse/COCOON-1963?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12488357
] 

Alexander Klimetschek commented on COCOON-1963:
-----------------------------------------------

To continue the story: generally it is not applicable to send a redirect to an XMLHttpRequest,
because it does not work at all in IE and other browsers don't like it either. The XHR always
expects content and the redirect in the HTTP cannot be interpreted when the browser does not
accpet the response at all. Thus the only feasible way is to encode the redirect inside the
XHR content.

An improvement might be the integration of this functionality in Cocoon itself, so that cocoon.redirectTo()
automatically detects the ajax request and sends the bu:redirect XML snippet. This would remove
the need for the RedirectTransformer, the select type="ajax-request" sitemap snippet and the
special pipeline you need to build for creating the redirect XML.

WDYT?

> Add a redirect action to the browser update handler
> ---------------------------------------------------
>
>                 Key: COCOON-1963
>                 URL: https://issues.apache.org/jira/browse/COCOON-1963
>             Project: Cocoon
>          Issue Type: New Feature
>          Components: Blocks: Ajax
>    Affects Versions: 2.1.10, 2.2-dev (Current SVN)
>            Reporter: Alexander Klimetschek
>         Attachments: BUHandler.js, RedirectTransformer.java
>
>
> In some situations you want to redirect the browser to a different page inside a cforms
action, eg. you have a REST-style interface and create something under the URL /new (which
shows a form to enter your new data) and on save you want to redirect the user to a page where
that new data is stored (e.g. /foobar42). To do so in an ajax-environment, where the save
action will be answered with a browser-update XML snippet, you need a separate action in the
browser update handler. This patch adds the handling of a simple "redirect" action to the
BUHandler.js:
>     <bu:document>
>         <bu:redirect uri="foobar42" />
>     </bu:document>
> If you want to have a fallback solution for non-AJAX cases, you need to trigger a normal
HTTP redirect from your pipeline. This must happen when this bu:redirect is inside the XML
stream, otherwise all content should be serialized to the browser. That functionality is provided
by the attached RedirectTransformer. The usage would be like:
>     <select type="ajax-request">
>         <when test="false">
>             <transform type="redirect" />
>         </when>
>     </select>
> The server-side javascript snippet for the save action should look like (form is the
Form object and documentID="foobar42"):
>     if (newDocument) {
>         form.getWidget().endProcessing(false);
>         cocoon.redirectTo("cocoon:/redirectTo/" + documentID);
>     }
> There should be a pipeline that matches "/redirectTo/*" and that serves the bu:document
like above (eg. via a jx template to insert the documentID).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message