bruno       2003/07/22 05:04:12

  Modified:    src/blocks/woody/samples/flow binding_example.js
  Log:
  Added form handler function
  
  Revision  Changes    Path
  1.2       +23 -1     cocoon-2.1/src/blocks/woody/samples/flow/binding_example.js
  
  Index: binding_example.js
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/flow/binding_example.js,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- binding_example.js        22 Jul 2003 11:51:42 -0000      1.1
  +++ binding_example.js        22 Jul 2003 12:04:12 -0000      1.2
  @@ -3,10 +3,32 @@
   function form2(form, documentURI, bindingURI) {
       var document = loadDocument(documentURI);
       var binding = loadBinding(bindingURI);
  +    var model = form.getModel();
   
       binding.loadFormFromModel(form.form, document);
   
  -    form.show("form2-display-pipeline", function() { return true; } );
  +    form.show("form2-display-pipeline", function(form) {
  +        print("submitId="+form.getSubmitId());
  +        switch(form.getSubmitId()) {
  +        case "remove-selected-contacts":
  +            {
  +                for (var i = model.contacts.length-1; i >= 0; i--) {
  +                    if (model.contacts[i].select) {
  +                        model.contacts.remove(i);
  +                    }
  +                }
  +            }
  +            break;
  +        case "add-contact":
  +            {
  +                model.contacts.length++;
  +            }
  +            break;
  +        default:
  +            return true;
  +        }
  +        return false;
  +    });
   
       binding.saveFormToModel(form.form, document);
       saveDocument(document, makeTargetURI(documentURI));
  
  
  

Reply via email to