Hi all,

I'm trying to make all the forms on 
www.superlinksoftware.com/cocoon/samples/bringmethis/ support a "modify" 
mode.  In order to do that I need to let the user enter his name and 
password, submit, and then retrieve the rest of the data and populate it 
into the next page's form.  I've been trying to do this by putting a 
call to getForm().setValue("/street","123 cherry tree lane") in the call 
to public Map perform(); but that doesn't seem to be working.  Nor does 
((UserBean)getForm().getModel()).setStreet("123 cherry tree lane").

So how do I populate data in the next form during the process of the 
previous?

Thank you kindly,

-Andy

Relevant excerpts:

 /**
   * Invoked after form population
   *
   * Semanticly similar to Struts Action.perform()
   *
   * Take appropriate action based on the command
   *
   */
  public Map perform ()
  {

    // get the actual model which this Form encapsulates
    // and apply additional buziness logic to the model
    UserBean  jBean = (UserBean) getForm().getModel();
    //jBean.incrementCount();

    // set the page control flow parameter
    // according to the validation result
    if ( getCommand().equals( CMD_NEXT ) &&
      getForm().getViolations () != null )
    {
      // errors, back to the same page
      return page( getFormView() );
    }
    else
    {
      // validation passed
      // continue with control flow

      // clear validation left overs in case the user
      // did not press the Next button
      getForm().clearViolations();

      // get the user submitted command (through a submit button)
      String command = getCommand();
      // get the form view which was submitted
      String formView = getFormView();

      if ( formView.equals ( VIEW_BUYERREG ) ) {
        if ( command.equals( CMD_NEXT ) && isModify() == false ) {
          return page(  VIEW_CONFIRM );
        } else if (command.equals( CMD_NEXT ) ) {
          UserBean  bean = (UserBean) getForm().getModel();
          if ( loadBuyerReg(bean) ) {
             Map  page = page(VIEW_BUYERREG);
             page.put("/email","[EMAIL PROTECTED]");
             return page;
          } else {
             return page(VIEW_MODIFY);
          }
        }
      }

      // apply control flow rules
      if ( formView.equals ( VIEW_CONFIRM ) ) {
        if ( command.equals( CMD_NEXT ) ) {
          try {registerUser(jBean);} catch (Exception e) {
             e.printStackTrace();
             return page( VIEW_FAILED );
          }
          return page(  VIEW_THANKS );
        }
      }
    }

    // should never reach this statement
    return page( VIEW_BUYERREG );

  }



  private boolean loadBuyerReg(UserBean userbean) {
      Form form = getForm();
      userbean.setUserName("BlaBla");
      form.setValue("/userName","blabla");
      userbean.setEmail("[EMAIL PROTECTED]");
      form.setValue("/email","[EMAIL PROTECTED]");
      form.save ( getObjectModel(), getFormScope() );
      userbean.setStreet("123 bla");
      userbean.setState("FL");
      userbean.setZip("13456");
      return true;
  }





---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to