Dan,

I would base the decision on how similar the actions are.
Some possible choices are:
1.  Use the same action with the same method as you describe.
2.  Use the same action but define two different methods within the action
based on what the user's role is.  This way you can include private methods
which can be common to both roles.
3.  Same as 2, except define a base action class and have two different
actions share that base class and define common methods in the base class.
4.  As you mention, completely separate actions, forms, and jsps.

I have used all of the above depending on the situation.  For example, in
one case, 6 different reports were being called, but all used the same
external call to run the reports and all shared 3 of the same lookup keys.
In this case I had a base report action class which defined all the common
methods and built additional report action classes for each report.  Then
when a report was added, I just created a new action based on my report base
and added whatever else I needed in the new class.

As far as the JSPs are concerned, if I find more than a couple if statements
in my JSP, I would make two separate pages instead.  I find it's easier to
maintain that way even though in some cases you will be making the same
changes in two different files.

In your case, I would suggest option 2 and possibly even the same JSP
page(s) if you could code it so the logic is all in the action.

Just my 2 cents,
-Rob

Rob Nocera
www.neosllc.com



-----Original Message-----
From: Dan Allen [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 12, 2004 12:41 PM
To: [EMAIL PROTECTED]
Subject: sharing actions with superuser

This seems to be a common design problem, so I figured i would take
it to the struts list for advice.  In my application, a user can
login and perform functions, such as viewing/altering one's own
profile.  Additionally, a user can have "superuser" priviledged, in
which case they can alter other user's profiles.  Would it be better
to split this into two actions or try to merge it in as a single
action?  If I did it as a single action, there would be a lot of

if (request.isUserInRole('ADMIN'))
{
    contact =
    contactFacade.getContact(request.getParameter('user'));
}
else
{
    contact = contactFacade.getContact(request.getRemoteUser()); 
}

within the action.  Additionally, different messages would be
needed, different forwards would be targeted and the views would be
different because they may need different messages, different return
pages, etc.

In short, it seems like I am performing the same action, but
in many ways it is more different than the same.  I sure which there
was a nice example of a "superuser" like interface that was
effecient.  Anyone have any thoughts or followup questions?

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <[EMAIL PROTECTED]>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Real programmers just hate to get up in the morning, and 
contrary to Ordinary People, they're in better shape as 
it gets closer to nighttime.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

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


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

Reply via email to