"ecn11" <[EMAIL PROTECTED]> writes:


> 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.

Dont do it this way. Implement an Action which fills the form with values.

What I usually (I use struts one month :-) do in such "edit something"
situations:

I create I an EditTgingActionForm with properties 
 a) the key properties
 b) the dependent properties 
 c) optional - a boolean indicator isEditing

I create an EditThingAction which:
 d) checks to see, whether the form has been filled from HTTP
     (which means: b) properties are filled and c) is true)
    if so, then it performs the updates. If not, no updates.

 e) fills the properties b) from the database using the key properties a).


In my JSP which leads to that action, i use parametrized link:
  <a href="editthing.do?id=BLA" > (generated with <html:link>)
  
As you see, properties b) or c) are not supplied, so the Action
knows, there is nothing to be updated, it just retrieves the data.

editthing.do then forward to a JSP, which displays the retrieved 
data and when submitted (again to editthing.do) EditThingAction
know, it has to update the data.

--
gR






Reply via email to