I respond to this query with a good deal of caution for the implementor
My analysis is that you will blow the stack when heaping children of parent
Action Classes as actions objects of class RequestProcessor ..lets take a
quick view of method processActionCreated
protected Action processActionCreate(HttpServletRequest request,
HttpServletResponse response,
ActionMapping mapping)
throws IOException {
// Acquire the Action instance we will be using (if there is one)
String className = mapping.getType();
if (log.isDebugEnabled()) {
log.debug(" Looking for Action instance for class " +
className);
}
// :TODO: If there were a mapping property indicating whether
// an Action were a singleton or not ([true]),
// could we just instantiate and return a new instance here?
Action instance = null;
synchronized (actions) {
// Return any existing Action instance of this class
instance = (Action) actions.get(className);
if (instance != null) {
if (log.isTraceEnabled()) {
log.trace(" Returning existing Action instance");
}
return (instance);
}
/*notice the reference to synchronized(actions) */
/*whereas the declarations for actions are protected HashMap actions = new
HashMap(); */
2 cautions
1)Since Hashmap derived from base class Map which has this doc
"While it is permissible for a map to contain itself as a value, extreme
caution is advised: the equals and hashCode methods are no longer well
defined on a such a map.."
what you are doing is putting a value of the (parent) action's instantiated
Action object action into the HashMap so what happens when you remove the
parent action but desire to access the action's (child) action from the
hashmap when the parent action has already been removed?? How does one gain
access to child when the parent action class was removed from HashMap??
2)
I am relatively certain we are violating the Polymorphic nature of a Java
Class here as well introducing a very probable deadlock scenario in the case
where perhaps child is accessing any method with synchronisation of the
parent was removed then child is now an essantially an orphaned object
Conclusion: Dont create another Action from your original Action Class
Anyone else???
Martin-
EEUU/Etats Unis/das Amerika
----- Original Message -----
From: "David G. Friedman" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Saturday, June 11, 2005 3:28 PM
Subject: RE: My IncludeAction-where to forward
Tony,
I suggest checking out a tiles Controller. It could create the menus for
you in a tile-based page WITHOUT needing to call multiple actions.
Details
on this can be found in Cedric Dumoulin's Tiles Advanced Features PDF.
Link: http://www.lifl.fr/~dumoulin/tiles/ with an instructional PDF in the
"Welcome" section listed as "Learn Tiles Advanced Features".
Struts-menu might fit but it depends on where and when you want to
instantiate your two menus.
Why do I recommend avoiding an Action calling another Action? Because it
requires the whole request chain to be processed again - request
parameters
and all. With a tiles action, you can have it in your template or only in
select pages, depending on your requirement, i.e. a member's menu that
might
only be on member pages or a generic menu for all pages. That is left up
to
you.
Again, this is just one of many opinions which might guide you on your way
to finding a solution that fits your situation and your coding style.
Regards,
David
-----Original Message-----
From: Tony Smith [mailto:[EMAIL PROTECTED]
Sent: Saturday, June 11, 2005 3:07 PM
To: Struts Users Mailing List
Subject: My IncludeAction-where to forward
My webapp is standard. It has a left side menu pane
and right side content pane. Both are dynamic and
generated by struts action. I would like to have two
different Actions for menu and content. For the menu
aciton, I would like to use IncludeAction so that is
could be included in my jsps.
Thus, I derived IncludeAction and put me stuff in
execute. But the problem is after everything is done,
where should the action go?
Here is my action code:
public class MenuAction extends IncludeAction {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse respose)
throws Exception {
//my stuff...
return mapping.????;
}
}
Here is my action defination in struts-config.xml:
<action
path="/menu"
type="xxx.MenuAction"
name="menuForm"
scope="request"
validate="true"
parameter="/pages/menu.jsp"/>
Could anyone help?
---------------------------------------------------------------------
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]