Thank you for replying.
I'm using POST.
The template for A is:
...
<ft:form-template action="" method="POST">
<div class="ficha">
<ft:widget id="delrestaurante"/>
<ft:widget id="nuevo"/>
<input type="submit" value="GUARDAR cambios" style="font-weight: bold;"/>
...
The template for B (if that matters):
...
<ft:form-template action="" method="POST">
<h2><ft:widget-label id="nombre"/></h2>
<p><ft:widget id="nombre"/></p>
...
I am not using any parameters on the URL query string.
2005/10/4, Sylvain Wallez <[EMAIL PROTECTED]>:
Antonio Fiol Bonnín wrote:
> 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" (=Add 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: [[EMAIL PROTECTED] <mailto: [EMAIL PROTECTED]>]
> [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 = cocoon.parameters["form-definition-a"];
> var formDefinitionB = cocoon.parameters["form-definition-b"];
> var bindingURIA = cocoon.parameters["bindingURI-a"];
> var bindingURIBPrefix = cocoon.parameters["bindingURI-b-prefix"];
> var saveURI = cocoon.parameters.saveURI;
> var saveXSLT = cocoon.parameters.saveXSLT;
> var displayPipelineLista = cocoon.parameters["displayPipeline-a"];
> var displayPipelineFicha = cocoon.parameters["displayPipeline-b"];
>
> var formLista = null;
> var formFicha = null;
> var formB = null;
>
> var datos = leerDatos(cocoon.parameters.loadURI); // Read the XML
> file and store into "datos"
>
> formLista = 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 = formLista.getWidget().getSubmitWidget();
> var idRestaurante = "";
>
> // Did the user not click the "Save changes" button?
> if(submitWidget!=null) {
> cocoon.log.info(submitWidget);
> // Did the user click "Add new"?
> if(submitWidget.id=="nuevo") {
> // To add a new record, we ask the repeater to do so.
> var repeater =
> submitWidget.parent.lookupWidget('restaurantes');
> repeater.addRow();
> // New record is last, so get the repeater size
> idRestaurante = repeater.size;
> } else {
> // Clicked "Edit", ... which row?
> idRestaurante =
> submitWidget.getParent().lookupWidget('id').value;
> }
> formLista.save(datos);
> formLista = null;
>
> // Prepare form B, using the ID for the new or edited record
> formFicha = createForm(formDefinitionB,
> bindingURIBPrefix+idRestaurante, datos);
>
> // ***********************
> // Form B is displayed on next line
> // ***********************
>
> formFicha.showForm(displayPipelineFicha);
> formFicha.save(datos);
> formFicha = null;
>
> formLista = createForm(formDefinitionA, bindingURIA, datos);
> } else {
> formLista.save(datos);
> }
> grabarDatos(saveURI, saveURI+".tmp", saveXSLT, datos);
>
> }
> }
>
> function createForm(definition, binding, datos) {
> var form = new Form(definition);
> if (binding != 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.
Do you use GET or POST methods in form A?
If you use GET, you display form B with a URL of the type
"page?continuation-id=contForA", which will be mixed with the hidden
"continuation-id" parameter in the form. Which one is sent first in the
request is browser-dependent, and it may be the case that posting puts
first the hidden field first whereas reloading just sends the
continuation for formA which is in the URL.
--
Antonio