cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivelin Ivanov" <ive...@apache.org>
Subject Re: Loading data in an Action with XMLForm
Date Fri, 23 Aug 2002 17:16:15 GMT

Sounds like the form is in the Request scope and in your case Session scope
would be more convenient.

Let me know if this helped.
If not, send me the code of your action.

Ivelin



----- Original Message -----
From: "Andrew C. Oliver" <acoliver@apache.org>
To: <cocoon-users@xml.apache.org>
Sent: Saturday, August 17, 2002 1:11 PM
Subject: Loading data in an Action with XMLForm


> 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","superbla@bla.bla");
>              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("blabla@bla.bla");
>       form.setValue("/email","blabla@bla.bla");
>       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:     <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>
>


---------------------------------------------------------------------
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:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message