Warning

Draft. To be continued for next monday 09/19/2005


Intent

Motivation

Architecture

http://www.bluexml.org/static/images/form-dp.gif

Controller

A controller manages and detects the mode the user is waiting for. At least 3 cases may be distinguished :

Implementation

This behavior may be coded with the following javascript in Cocoon 2.1 :

function dispatch() {
    // Initialization from default files
    // ---------------------------------
    if (('create' == action)||('search' == action)) {
        documentURI = tmpPath + "/tmp/" + docType + "-new.xml";
    } else {
        documentURI = cocoon.parameters["documentURI"];
    }   

    var bindingURI = cocoon.parameters["bindingURI"];
    var formToShowPrefix = cocoon.parameters["formToShow"];
    var formToShow;

    if (action.indexOf('review',0) != -1) {
        formToShow = formToShowPrefix + "-review";
    } else if ('read' == action) {
        formToShow = formToShowPrefix + "-read";
    } else if ('create' == action) {
        formToShow = formToShowPrefix + "-create";      
    } else if ('search' == action) {
        formToShow = formToShowPrefix + "-search";
    }

    if (docType) {    
        // Initialization from code. It should be better located in form definition
        // ------------------------------------------------------------------------
        var factory = new FormFactory();
        var aObject = factory.createForm(this, docType);                

        // Call display service
        // --------------------
        var result = display(action, aObject, form, documentURI, bindingURI, formToShow, tmpPath);

        // Call service
        // ------------
        if (100 == result) {
            // init problem
        } else if ( 3 == result) {
            var target = "process-errorsuffix";
            cocoon.sendPage(target);
        } else {
            if ('create' == action) {
                var target = "process-create-" + aObject.getData();
                cocoon.sendPage(target);
            } else if ('search' == action) {
                var target = "process-qbe-tmp-" + aObject.getData();
                cocoon.sendPage(target);
            } else {
                // Review action
                var target = "process-update-" + docid + "-" + aObject.getData();
                cocoon.sendPage(target);
                }
            }
        } else {
            var target = "read/process-list-" + doctype + "-" + category;
            cocoon.sendPage(target);
        }
}

More information

This web page is available in html format on http://www.bluexml.org. You may have help on cocoon or bluexml mailing lists.

JCKermagoret

DesignPattern/FormProcessing (last edited 2009-09-20 23:41:56 by localhost)