cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/woody/samples/flow binding_example.js
Date Wed, 23 Jul 2003 15:20:49 GMT
bruno       2003/07/23 08:20:49

  Modified:    src/blocks/woody/samples/flow binding_example.js
  Log:
  Added a bean-binding sample
  
  Revision  Changes    Path
  1.4       +30 -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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- binding_example.js	22 Jul 2003 20:59:08 -0000	1.3
  +++ binding_example.js	23 Jul 2003 15:20:49 -0000	1.4
  @@ -58,7 +58,7 @@
   // the form2 function is not directly called by the sitemap but by
   // a generic "woody" function that instantiates the form based on
   // parameters passed from the sitemap (see woody.js file)
  -function form2(form, documentURI, bindingURI) {
  +function form2xml(form, documentURI, bindingURI) {
       // document contains the document to be edited as a DOM tree
       // (loadDocument is an utility function that looks up the
       //  Avalon DOMParser component to parse the file)
  @@ -88,6 +88,35 @@
       saveDocument(document, makeTargetURI(documentURI));
   
       cocoon.sendPage("form2-success-pipeline");
  +    form.finish();
  +}
  +
  +// bean variant of the binding sample
  +function form2bean(form, documentURI, bindingURI) {
  +    var bean = new Packages.org.apache.cocoon.woody.samples.Form2Bean();
  +
  +    // fill bean with some data to avoid users having to type to much
  +    bean.setEmail("yourname@yourdomain.com");
  +    bean.setIpAddress("10.0.0.1");
  +    bean.setPhoneCountry("32");
  +    bean.setPhoneZone("2");
  +    bean.setPhoneNumber("123456");
  +    var contact = new Packages.org.apache.cocoon.woody.samples.Contact();
  +    contact.setId("1");
  +    contact.setFirstName("Herman");
  +    bean.addContact(contact);
  +
  +    var binding = loadBinding(bindingURI);
  +
  +    binding.loadFormFromModel(form.form, bean);
  +
  +    form.show("form2-display-pipeline", formHandler);
  +
  +    binding.saveFormToModel(form.form, bean);
  +
  +    print(bean.toString());
  +
  +    cocoon.sendPage("form2bean-success-pipeline", { "form2bean": bean });
       form.finish();
   }
   
  
  
  

Mime
View raw message