cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roberto Marra" <rma...@montefiore.ch>
Subject Re: CForms & value of field...
Date Wed, 18 May 2005 14:45:52 GMT
I mean... sorry if I didn't clarify myself...
Im looking at the samples "../block/forms/flow/binding_example.js". This is the flowscript:

function form2bean(form) {
    var bean = new Packages.org.apache.cocoon.forms.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");
      bean.setBirthday(new java.util.Date());
      bean.setSex(Packages.org.apache.cocoon.forms.samples.Sex.MALE);
    
      var contact = new Packages.org.apache.cocoon.forms.samples.Contact();
      contact.setId("1");
      contact.setFirstName("Roberto");
      contact.setLastName("Marra");
      contact.setPhone("+41916104455");
      contact.setEmail("rmarra@montefiore.ch");
      
    bean.addContact(contact);

    
    form.load(bean);
    form.showForm("form2-display-pipeline");
    form.save(bean);

    cocoon.sendPage("form2bean-success-pipeline", { "form2bean": bean });
}

The bean is used to fill-up the field of the form. What I need is retrive the value of the
field of the form. I already did something like 

bean.setEmail("cocoon.parameters["email"]");

But as I wrote if I got 300field I would like to find another solution...

hope that I clarify..

  ----- Original Message ----- 
  From: Roberto Marra 
  To: users@cocoon.apache.org 
  Sent: Wednesday, May 18, 2005 4:14 PM
  Subject: Re: CForms & value of field...


  Hi Jeroen & thanx.
  I had a look of the OJB samples. Let say that now my main target is not to write to db but
to have the value of the CForm available in the flowscript & I want to do that via binding.
So in the sitemap I got that now:

  <map:match pattern="regContatti">
  <map:call function="handleForm">
  <map:parameter name="function" value="storeContact"/>
  <map:parameter name="form-definition" value="forms/definitions/contatti.xml"/>
  <map:parameter name="bindingURI" value="binding/contatti/bindContatti.xml"/>
  </map:call>
  </map:match>

  & in the flowscript
  ...
     var bindingFile =  cocoon.parameters["bindingURI"];
     var bean = new Packages.org.mf.ContactBean();

     form.createBinding(bindingFile);
     form.save(bean);

     System.out.println("test:"+form.lookupWidget("ragSoc").getValue());

  ...

    but "test" return me null. So for sure I didn't understand something...or more...

  Cheers
  ROberto




    ----- Original Message ----- 
    From: Jeroen Reijn 
    To: users@cocoon.apache.org 
    Sent: Wednesday, May 18, 2005 9:52 AM
    Subject: RE: CForms & value of field...


    Hi Roberto,

    I think binding the form could be a great solution for your problem. You could check out
the OJB samples to see how to write to the DB.

    Greetz,

    Jeroen
      -----Original Message-----
      From: Roberto Marra [mailto:rmarra@montefiore.ch]
      Posted At: Wednesday, May 18, 2005 9:23 AM
      Posted To: Cocoon User List
      Conversation: CForms & value of field...
      Subject: CForms & value of field...


      Hi all,
      I guess I missed something about the process of get value from the CForm to the flowscript.
So hope somebody can clarify me it.

      I got a CForm definition file & a template. Then in my pipeline I got a match pattern
that call a function & pass the parameter of the CForm in this way:

           <map:parameter name="ragSoc" value="{request-param:ragSoc}"/>
           <map:parameter name="indirizzo" value="{request-param:indirizzo}"/>
           <map:parameter name="cap" value="{request-param:cap}"/>
           <map:parameter name="citta" value="{request-param:citta}"/>
           <map:parameter name="nazione" value="{request-param:nazione}"/>
           <map:parameter name="telefono" value="{request-param:telefono}"/>

      then, in my flowscript I do that:

          ragSoc    = cocoon.parameters["ragSoc"];
          indirizzo = cocoon.parameters["indirizzo"];
          cap       = cocoon.parameters["cap"];
          citta     = cocoon.parameters["citta"];
          nazione   = cocoon.parameters["nazione"];
          telefono  = cocoon.parameters["telefono"];
          email     = cocoon.parameters["email"];
          lingua    = cocoon.parameters["lingua"];
          pwd       = cocoon.parameters["pwd"];
          confpwd   = cocoon.parameters["confpwd"];

      & then I call a Java method & I do what I have to do (in this case write the
value in the db). So, that could be interesting for one CForm, but Im making an application
programm, with a lot of CForms with a lot of field. Im sure I have not to send everytime all
the field in this way to flowscript, Im sure there is an elegant way to do that. Is the binding
file the solution? I saw different example of binding but in the example the binding is used
most of the time to write data in the CForms..

      Any suggestion?

      Thanx in advance
      Roberto







Mime
View raw message