-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ney,

Ney André de Mello Zunino wrote:
> What I had to do was create a new ActionForward and set its attributes:
> 
> ActionForward newAction = new ActionForward();
> newAction.setPath(fwdAction.getPath() + ...);
> newAction.setRedirect(true);
> return newAction;

I do the same thing, but I've written a class to help wrap all that
logic so it's easier to do so. The class even wraps an existing
ActionForward and extends it, so it acts just like a regular
ActionForward except that you can add parameters and even an anchor to
it. You can find the code for it as an attachment to this Struts
enhancement request: http://issues.apache.org/bugzilla/show_bug.cgi?id=36037

Struts comes with something like this already
(org.apache.struts.action.ActionRedirect).

> Now what I am trying to understand is why this is the case. Is is
> because ActionForwards defined in the config file are not supposed to be
> modified? I am just beginning with Struts, so please bear with me.

The reason that you shouldn't be modifying these objects is that they
are intended to be created once and used many times. Struts loads its
configuration into a series of objects in memory and doesn't want you to
modify that configuration during runtime. If you were to change the
parameters for a particular ActionForward, then they would be changed
for every use of that ActionForward thereafter. It would be a mess.

So, the developers chose a solution that would be conservative on memory
(only one object ever created for an ActionForward in the config file)
and processor time (don't have to waste time creating and initializing
those objects). In order to protect from accidental changes, these
objects are "locked" after they are configured to make sure that folks
like you don't stumble into a situation where your Struts app starts
doing seriously unexpected things.

Look into using ActionRedirect. Or, if you want a touch more
flexibility, use my class found in the bug mentioned above.

Hope that helps,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFo8Up9CaO5/Lv0PARAnM0AJwNogfxrU2Ly/M5zu3DZwe5q2fD0ACffy4N
SQryCdnDNf+bBBf2CY3IjeQ=
=b7NR
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to