I just noticed that you have the user at 2 places: inside the model and in
an instance variable. Set the searched user on those 2 places, or only use
the model to keep the user object.

On Mon, Feb 28, 2011 at 4:23 PM, Bob Peterson <gp...@yahoo.com> wrote:

> Hi Pedro, thank you for your reply.
>
> In the applyState() of the first step (UserSearchStep) i added the
> following.
> However, my second step still displays the user info from the first search,
> am i
> correctly getting the form?
>
>            Form f = (Form)UserSearchStep.this.findParent(Form.class);
>            f.modelChanged();
>
> i've also tryed
>
>            Form f = NewUserWizard.this.getForm();
>            f.modelChanged();
>
>
>
>
> ----- Original Message ----
> From: Bob Peterson <gp...@yahoo.com>
> To: users@wicket.apache.org
> Sent: Mon, February 28, 2011 7:32:08 PM
> Subject: Wizard (updating model)
>
> Greetings,
>
> I'm a newbie trying to use the wizard from the extensions package to search
> and
> update a user in a database.  My first step has a single RequiredTextField
> where
>
> the userid is entered.  When the user clicks the next button I search the
> database and update the User object and display the second step with the
> users
> info.  This works good.  However, if I click the back button and enter a
> different userid then click next again the second step still diplays the
> results
>
> from the first search.  The second step doesn't seem to recognize the the
> model
> has changed.  I've verified that the User object (the model) does get
> updated
> with all the new info for the searched userid.  I'm updating the User
> object in
> a method which is called in the overriden applyState() method, is this the
> correct place to update a model?
>
> Any help would be appreciated.
>
> Parts of the code.
>
> public class NewUserWizard extends Wizard {
>
>    private final class UserSearchStep extends WizardStep
>    {
>        private static final long serialVersionUID = 1L;
>
>        public UserSearchStep()
>        {
>            super();
>            add(new RequiredTextField<String>("userid", new
> PropertyModel<String>(user, "userid")));
>
>        }
>
>        @Override
>        public void applyState() {
>            super.applyState();
>
>            NewUserWizardHelper.userSearch(user.getUserid, user);  // <---
> I've
> verified that the user (User object) is being updated in the method.
>
>               //NewUserWizard.this.setUser(user);   <-- this doesn't work
> either.
>            //modelChanged();
>
>        }
>
>
>    }
>
>    private final class UserInfoStep extends WizardStep
>    {
>        private static final long serialVersionUID = 1L;
>
>        private RequiredTextField surname;
>
>        public UserInfoStep()
>        {
>            super();
>
>            //surname = new RequiredTextField("surname");
>
>            surname = new RequiredTextField("surname", new
> PropertyModel<User>(user, "surname") );
>            add(surname);
>        }
>    }
>
>    private User user;
>
>    public NewUserWizard(String id)
>    {
>        super(id);
>
>        // create a blank user
>        user = new User();
>
>        setDefaultModel(new CompoundPropertyModel<User>(user));
>        //setDefaultModel(new CompoundPropertyModel<NewUserWizard>(this));
>
>        WizardModel model = new WizardModel();
>        model.add(new UserSearchStep());
>        model.add(new UpdateInfoStep());
>
>        // initialize the wizard with the wizard model we just built
>        init(model);
>    }
>
>    public User getUser() {
>        return user;
>    }
>
>    public void setUser(User user) {
>        this.user = user;
>    }
>
>
> }
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Pedro Henrique Oliveira dos Santos

Reply via email to