Hi.

I apologize for this probably really stupid question, but I was not able to
find a suitable answer anywhere, yet...

In my user management I want to provide a way that the users can change
their address (they are already stored in a database). Thus I need a form
with the old address as initial values.

In other words: There is a session variable "UserId". How can the form bean
that is used by "edituser.jsp" access this userid to adjust it's initial
values.

I can write >>name = "peter";<< in the constructor of my EditUserForm class.
But I want that the name is taken from a database depending on the UserId of
the session.

public void reset(ActionMapping mapping,
javax.servlet.http.HttpServletRequest request) seems not to be executed.

Is something like that the right way:

public class EditUserForm extends ActionForm {
        protected boolean initialized = false;
        protected String name;
        String getName() {
                if ( !initialized ) doInitialize();
                return name;
        }
        public void setName(String name) {
                this.name = name;
        }
        public void doInitialize() {
                name = get Name from Database... (but how can I access the
sessionvariables here?)
                initialized = true;
        }
}

Is there a new instance of EditUserForm created each time a user accesses
the page?

Dominic

Reply via email to