Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 2961 invoked from network); 4 Oct 2005 16:17:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Oct 2005 16:17:02 -0000 Received: (qmail 26558 invoked by uid 500); 4 Oct 2005 16:16:56 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 26514 invoked by uid 500); 4 Oct 2005 16:16:56 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: users@cocoon.apache.org List-Id: Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 26501 invoked by uid 99); 4 Oct 2005 16:16:56 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2005 09:16:56 -0700 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=HTML_40_50,HTML_MESSAGE,RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of antonio.fiol@gmail.com designates 64.233.184.204 as permitted sender) Received: from [64.233.184.204] (HELO wproxy.gmail.com) (64.233.184.204) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2005 09:17:00 -0700 Received: by wproxy.gmail.com with SMTP id 69so94149wri for ; Tue, 04 Oct 2005 09:16:34 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type; b=rY2i0flcVWz0KdaA7CosiMpexroyP34kkziMKf6bxt3uPmjUq1iL2R6oJnI/XAqUAY2Ijg+1Jn4i8ZUbwo0HkcmWi9ZYGse+ra4Fsf2bZAyuV5AbFFAA7NC5tAy43EdkOd83yo6P+N1EWieCweNH/HriYf9vcoxPXI1higOYu1Y= Received: by 10.54.103.4 with SMTP id a4mr612814wrc; Tue, 04 Oct 2005 09:16:34 -0700 (PDT) Received: by 10.54.89.5 with HTTP; Tue, 4 Oct 2005 09:16:34 -0700 (PDT) Message-ID: Date: Tue, 4 Oct 2005 18:16:34 +0200 From: =?ISO-8859-1?Q?Antonio_Fiol_Bonn=EDn?= Reply-To: =?ISO-8859-1?Q?Antonio_Fiol_Bonn=EDn?= To: users@cocoon.apache.org Subject: flow problem with reload button MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_10510_9449552.1128442594304" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_10510_9449552.1128442594304 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello, I am having strange problems (described below) when hitting the "reload" button on my browser when displaying form B in scenario described below. Could anyone please help me understand why? I am using a 2-form approach to editing an XML file, one for a first level view and a deeper detail editing view. Form "A" only contains a repeater with a "nombre" widget for each row, plus all the necessary widgets for deleting selected rows. It also has a submit called "nuevo" (=3DAdd new, see below for js code managing it), a standard HTML submit button, and an edit submit button on each row. Example: [Delete selected] [Add new] [Save changes] [X] [Edit] Name1 [X] [Edit] Name2 [X] [Edit] Name3 [X] [Edit] Name4 Form "B" is bound to the same XML file, but with more fields and attributes mapped to form widgets, but it only maps a certain part of the XML. Example: Name: [Name1] E-mail: [a@b.c] [Save changes] So the binding for B is dynamically generated by a pipeline. The flow should be A->B->A if "Edit" or "Add new" are used. A->A if "delete selected" or "save changes" are used. function editarRestaurantes() { // Keep important things in vars, as they will be lost from cocoon.parameters var formDefinitionA =3D cocoon.parameters["form-definition-a"]; var formDefinitionB =3D cocoon.parameters["form-definition-b"]; var bindingURIA =3D cocoon.parameters["bindingURI-a"]; var bindingURIBPrefix =3D cocoon.parameters["bindingURI-b-prefix"]; var saveURI =3D cocoon.parameters.saveURI; var saveXSLT =3D cocoon.parameters.saveXSLT; var displayPipelineLista =3D cocoon.parameters["displayPipeline-a"]; var displayPipelineFicha =3D cocoon.parameters["displayPipeline-b"]; var formLista =3D null; var formFicha =3D null; var formB =3D null; var datos =3D leerDatos(cocoon.parameters.loadURI); // Read the XML file an= d store into "datos" formLista =3D createForm(formDefinitionA, bindingURIA, datos); while(true) { // display form A formLista.showForm(displayPipelineLista); // ********************************* // If I hit reload when form B is displayed, execution is resumed here, but formLista is undefined // Why is it "null"? Shouldn't it be restored to the previous value because of my hitting "Reload". // ********************************* var submitWidget =3D formLista.getWidget().getSubmitWidget(); var idRestaurante =3D ""; // Did the user not click the "Save changes" button? if(submitWidget!=3Dnull) { cocoon.log.info(submitWidget); // Did the user click "Add new"? if(submitWidget.id=3D=3D"nuevo") { // To add a new record, we ask the repeater to do so. var repeater =3D submitWidget.parent.lookupWidget('restaurantes'); repeater.addRow(); // New record is last, so get the repeater size idRestaurante =3D repeater.size; } else { // Clicked "Edit", ... which row? idRestaurante =3D submitWidget.getParent().lookupWidget('id').value; } formLista.save(datos); formLista =3D null; // Prepare form B, using the ID for the new or edited record formFicha =3D createForm(formDefinitionB, bindingURIBPrefix+idRestaurante, datos); // *********************** // Form B is displayed on next line // *********************** formFicha.showForm(displayPipelineFicha); formFicha.save(datos); formFicha =3D null; formLista =3D createForm(formDefinitionA, bindingURIA, datos); } else { formLista.save(datos); } grabarDatos(saveURI, saveURI+".tmp", saveXSLT, datos); } } function createForm(definition, binding, datos) { var form =3D new Form(definition); if (binding !=3D null) { form.createBinding(binding); } form.load(datos); return form; } Thank you very much for any hint, and sorry for the long e-mail. I tried hard to make it shortest possible. -- Antonio ------=_Part_10510_9449552.1128442594304 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello,

I am having strange problems (described below) when hitting the "reload" button on my browser when displaying form B in scenario described below. Could anyone please help me understand why?

I am using a 2-form approach to editing an XML file, one for a first level = view and a deeper detail editing view.

Form "A" only contains a repeater with a "nombre" widge= t for each row, plus all the necessary widgets for deleting selected rows.
It also has a submit called "nuevo" (=3DAdd new, see below for js= code managing it), a standard HTML submit button, and an edit submit button on each row.

Example:
[Delete selected] [Add new] [Save changes]
[X] [Edit] Name1
[X] [Edit] Name2
[X] [Edit] Name3
[X] [Edit] Name4

Form "B" is bound to the same XML file, but with more fields and attributes mapped to form widgets, but it only maps a certain part of the XML.

Example:
Name: [Name1]
E-mail: [a@b.c]
[Save changes]

So the binding for B is dynamically generated by a pipeline.

The flow should be
A->B->A if "Edit" or "Add new" are used.
A->A if "delete selected" or "save changes" are used= .

function editarRestaurantes() {
    // Keep important things in vars, as they will be lost f= rom cocoon.parameters
    var formDefinitionA =3D cocoon.parameters["form-def= inition-a"];
    var formDefinitionB =3D cocoon.parameters["form-def= inition-b"];
    var bindingURIA =3D cocoon.parameters["bindingURI-a= "];
    var bindingURIBPrefix =3D cocoon.parameters["bindin= gURI-b-prefix"];
    var saveURI =3D cocoon.parameters.saveURI;
    var saveXSLT =3D cocoon.parameters.saveXSLT;
    var displayPipelineLista =3D cocoon.parameters["dis= playPipeline-a"];
    var displayPipelineFicha =3D cocoon.parameters["dis= playPipeline-b"];

    var formLista =3D null;
    var formFicha =3D null;
    var formB =3D null;

    var datos =3D leerDatos(cocoon.parameters.loadURI); // R= ead the XML file and store into "datos"

    formLista =3D createForm(formDefinitionA, bindingURIA, d= atos);

    while(true) {

         // display form A
         formLista.showForm(display= PipelineLista);

// *********************************
// If I hit reload when form B is displayed, execution is resumed here, but= formLista is undefined
// Why is it "null"? Shouldn't it be restored to the previous val= ue because of my hitting "Reload".
// *********************************
      
        var submitWidget =3D formLista.g= etWidget().getSubmitWidget();
        var idRestaurante =3D "&quo= t;;

        // Did the user not click the &q= uot;Save changes" button?
        if(submitWidget!=3Dnull) {
            cocoon.l= og.info(submitWidget);
            // Did t= he user click "Add new"?
            if(submi= tWidget.id=3D=3D"nuevo") {
            &nb= sp;   // To add a new record, we ask the repeater to do so.
            &nb= sp;   var repeater =3D submitWidget.parent.lookupWidget('restaurantes');
            &nb= sp;   repeater.addRow();
            &nb= sp;   // New record is last, so get the repeater size
            &nb= sp;   idRestaurante =3D repeater.size;
            } else {=
            &nb= sp;   // Clicked "Edit", ... which row?
            &nb= sp;   idRestaurante =3D submitWidget.getParent().lookupWidget('id').value;
            }
            formList= a.save(datos);
            formList= a =3D null;

            // Prepa= re form B, using the ID for the new or edited record
            formFicha =3D createForm(formDefinitionB, bindingURIBPrefix+idRestaurante, datos);

// ***********************
// Form B is displayed on next line
// ***********************

            formFich= a.showForm(displayPipelineFicha);
            formFich= a.save(datos);
            formFich= a =3D null;

            formList= a =3D createForm(formDefinitionA, bindingURIA, datos);
        } else {
            formList= a.save(datos);
        }
        grabarDatos(saveURI, saveURI+&qu= ot;.tmp", saveXSLT, datos);

    }
}

function createForm(definition, binding, datos) {
    var form =3D new Form(definition);
    if (binding !=3D null) {
        form.createBinding(binding);
    }
    form.load(datos);
    return form;
}



Thank you very much for any hint, and sorry for the long e-mail. I tried ha= rd to make it shortest possible.

--
Antonio ------=_Part_10510_9449552.1128442594304--