The first thing to remember is that a Forward is just a Java object. You can create them and manipulate them in any way that you want.

For instance, in our application we didn't want the users to use the "Back" button on their browser. We hid the toolbar, disabled the necessary shortcuts, and wrote our own server-side mechanism. From a Struts standpoint, this means that what happens when you hit the "Back" button (on the web page) is completely dynamic. There was no way to use static forwards defined in the struts-config file to implement that functionality.

What I did to implement the navigation aspects of this was to create custom ActionMapping and RequestProcessor classes. The findForward method in my custom ActionMapping will create a new instance of an ActionForward (without a path attribute) when the back button is pressed. (I use a static String attribute in ActionMapping as the name of the forward.) When the RequestProcessor sees one of these forwards, it accesses the session history and sets the path attribute on the ActionForward prior to processing it.

In your case, you could do something similar by creating two "pre-defined" forwards in a custom ActionMapping: CustomerSummary and CustomerOverview. In your request processor, just detect when a forward has one of these two names and access the customer information to manipulate the path attribute.

Just one possibility

-- Jeff

Bent André Solheim wrote:
Hi Struts users,

I am developing a web based reporting system using Struts, and one
requirement is that each customer can have their own tailored version
of the reports.

I use tiles to define each report page for each customer, and for each
page for each customer I define a <forward> element in the
<global-forwards>. In the Actions, I look up what Customer is
performing the Action and return the approprate ActionForward. This
works just fine functionally, but it is turning into a maintenance
issue.

In struts-config.xml, I have a <forward> element for each customer for
each report page where the name and path is prefixed with a
CustomerId;

...
<forward name="customer1id.summary" path="customer1id.summary" ... />
<forward name="customer2id.summary" path="customer2id.summary" ... />
<forward name="customer3id.summary" path="customer3id.summary" ... />
<forward name="customer1id.overview" path="customer1id.overview" ... />
<forward name="customer2id.overview" path="customer2id.overview" ... />
...

where the path is tiles definition names. I realise that I must have a
unique path for each report page for each Customer, but ideally I
would not declare these in struts-config.xml, and in my Actions, I
would not look up the Customer performing the Action, but just return
a Customer ignorant forward;

in my Action:
...
return mapping.findForward("summary");

in struts-config.xml
<forward name="summary" path="summary" ... />

and then plug in some kind of mechanism to the struts framework that
was able to determine the forward path for the current Customer for
the given forward name.

This would save me a lot of typing in the struts-config.xml and would
clean up my Action classes of the necessary customer aware forward
lookup.

Am I making any sense here? Have anybody had similary issues and found
a decent solution that they would like to share? Is the solution I
described possible to implement easily?

Best Regards
Bent André


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



Reply via email to