what is that:

propertyModel = new PropertyModel(accountPage.getUser(),
            RequiredFieldContainer.CLASSIFIED_ACCOUNT_TYPE);

where is that model used?

and why are you making a new model why net just set the model object on the form itself?
form.setModelObject(user)

johan

On 4/27/06, Andrew Strickland <[EMAIL PROTECTED] > wrote:
At wit's end here so I'm going to post my code.  Can't for the life of me figure out why the form won't reset, even when I re-initialize the underlying model object.
 
Code follows:
 
AccountPage.java
 
public class AccountPage extends DefaultPage
{
   /* The user to edit, or null (for a new user) */
   private User user;
   public AccountPage(PageParameters parameters)
   {
      super("Account");
      String accountId = parameters.getString("accountId");
      User theUser = UserProvider.getInstance().getUserByAccountID(accountId);
 
      /* The is a new account, new up a User as our Model object */
      if (theUser == null)
      {
         theUser = new User();
      }
 
      setUser(theUser);
      addInstructions();
      addAccountPanel();
   }
 
...
 
 public void addAccountPanel()
   {
      add(new AccountPanel("accountPanel", this));
   }
 
AccountPanel.java
 
public AccountPanel(String id, AccountPage accountPage)
   {
      super(id);
 
      this.accountPage = accountPage;
 
      model = new BoundCompoundPropertyModel(accountPage.getUser());
 
      propertyModel = new PropertyModel(accountPage.getUser(),
            RequiredFieldContainer.CLASSIFIED_ACCOUNT_TYPE);
 
      accountForm = new Form("accountForm", model);
 
      add(accountForm);
 
...
 
down in the submit button's onSubmit (still inside AccountPanel.java)...
 
Button submitButton = new Button("submitButton", new Model())
      {
         protected void onSubmit()
         {
            /*
             * See below comment in the cancel button concerning the null
             * response page
             */
            cancelResponsePage();
            /*
             * If user already exists, update the user. Otherwise create the
             * user.
             */
            if (UserProvider.getInstance().userExists(accountPage.getUser()))
            {
               UserProvider.getInstance().updateUser(accountPage.getUser(),
                     true);
               resetForm();
               getPage().getResponse().redirect(
                     (String)accountPage.getWp2fSession().getHttpSession()
                           .getAttribute(SessionConstants.ORIGINAL_REFERRER ));
            }
            else
            {
               UserProvider.getInstance().addUser(accountPage.getUser());
               /*
                * Reprint, review, whatever. Shows instructions, pops up the
                * SAAR.
                */
               String response = "/reprintUserRegistration.jsp?token="
                     + accountPage.getUser().getToken() + "&accountType="
                     + accountPage.getUser ().getAccountType();
               resetForm();
               getPage().getResponse().redirect(
                     accountPage.getContextPath() + response);
            }
         }
      };
 
...
 
 /**
    * Reset the model of the page, form, etc.
    *
    * Subsequent visits to the page should show up with no data already entered.
    */
   private void resetForm()
   {
      User user = new User();
      model = new BoundCompoundPropertyModel(user);
      accountForm.setModel(model);
   }
 
 
 
Any insight would be much appreciated :)
 
Andy

Reply via email to