You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Alexander Klimetschek (JIRA)" <ji...@apache.org> on 2006/12/05 18:30:21 UTC

[jira] Created: (COCOON-1963) Add a redirect action to the browser update handler

Add a redirect action to the browser update handler
---------------------------------------------------

                 Key: COCOON-1963
                 URL: http://issues.apache.org/jira/browse/COCOON-1963
             Project: Cocoon
          Issue Type: New Feature
          Components: Blocks: Ajax
    Affects Versions: 2.2-dev (Current SVN), 2.1.10-dev (current SVN)
            Reporter: Alexander Klimetschek


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.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (COCOON-1963) Add a redirect action to the browser update handler

Posted by "Alexander Klimetschek (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Updated: (COCOON-1963) Add a redirect action to the browser update handler

Posted by "Alexander Klimetschek (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1963?page=all ]

Alexander Klimetschek updated COCOON-1963:
------------------------------------------

    Attachment: RedirectTransformer.java

The RedirectTransformer with a different package name. Should IMHO go into cocoon ajax, just next to the BrowserUpdateTransformer.

> Add a redirect action to the browser update handler
> ---------------------------------------------------
>
>                 Key: COCOON-1963
>                 URL: http://issues.apache.org/jira/browse/COCOON-1963
>             Project: Cocoon
>          Issue Type: New Feature
>          Components: Blocks: Ajax
>    Affects Versions: 2.2-dev (Current SVN), 2.1.10-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.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (COCOON-1963) Add a redirect action to the browser update handler

Posted by "Alexander Klimetschek (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1963?page=all ]

Alexander Klimetschek updated COCOON-1963:
------------------------------------------

    Attachment: BUHandler.js

Not a patch, but the entire new version of BUHandler.js (sorry, but I currently don't have the environment to test it out directly in cocoon-ajax)

> Add a redirect action to the browser update handler
> ---------------------------------------------------
>
>                 Key: COCOON-1963
>                 URL: http://issues.apache.org/jira/browse/COCOON-1963
>             Project: Cocoon
>          Issue Type: New Feature
>          Components: Blocks: Ajax
>    Affects Versions: 2.2-dev (Current SVN), 2.1.10-dev (current SVN)
>            Reporter: Alexander Klimetschek
>         Attachments: BUHandler.js
>
>
> 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.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira