struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Cooper" <>
Subject Re: newbie: initial values
Date Wed, 01 Aug 2001 23:21:33 GMT
If the new parameter is fixed, you can put this into the foward entry in
struts-config like this:

    <forward name="success" path="/" />

If the parameter value is dynamic, and needs to be set by the action, how
about this:

    ActionForward fwd = mapping.findForward("success");
    return new ActionForward(fwd.getPath() + "?id=BLA", fwd.getRedirect());


1) This assumes that the path for the forward in struts-config does not
include a query string. To be more robust, you should really check for that
before appending your new parameter.

2) If you "know" that the forward is a 'forward' or a 'redirect', you can
simplify the above by using ForwardingActionForward or
RedirectingActionForward instead of ActionForward. However, it's safer to
not make any assumptions, and use the code fragment above.

Hope this helps.

Martin Cooper

----- Original Message -----
From: "ecn11" <>
To: <>
Sent: Thursday, July 26, 2001 4:53 AM
Subject: AW: newbie: initial values


Thank you very much. The way you have described works really fine...

But now I have another problem:

After saving the form my ActionForward perform(...) returns
mapping.findForward("success"); Is there a way of generating the
"" again - that is adding a "?id=BLA" to the
mapping that the findForward generated... I have to edit further properties
of the same "somthing" in the next form.


-----Urspr√ľngliche Nachricht-----
Von: Gregor Rayman []
Gesendet: Mittwoch, 25. Juli 2001 14:58
Betreff: Re: newbie: initial values

"ecn11" <> writes:

> Hi.
> I apologize for this probably really stupid question, but I was not able
> 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
> 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"

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="" > (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. then forward to a JSP, which displays the retrieved
data and when submitted (again to EditThingAction
know, it has to update the data.


View raw message