Hi Bob, call Form#modelChanged in applyState to indicate the change.

On Mon, Feb 28, 2011 at 2:32 PM, Bob Peterson <[email protected]> wrote:

> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Pedro Henrique Oliveira dos Santos

Reply via email to