You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Tony Smith <qu...@yahoo.com> on 2005/06/11 21:07:27 UTC
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?
--- Ray Madigan <ra...@madigans.org> wrote:
> I would advise you read the sections
> http://struts.apache.org/userGuide/introduction.html
> that explain how an
> ActionForm works and how you get/set the form
> properties.
>
> You need an ActionForm linked to your Action and
> struts will scrape the
> properties from your page into the form and you just
> manage the form.
>
> -----Original Message-----
> From: Joe Smith [mailto:strutsng@gmail.com]
> Sent: Friday, June 10, 2005 11:01 PM
> To: user@struts.apache.org
> Subject: display the form values from view page
>
>
> register.jsp is the view page, and when the user
> click submit button,
> it will go to result.jsp based on struts-config.xml.
> The followings
> are the code fragment of each significant files.
>
> My question is for result.jsp, I am now using
> request.getParameter("name")
> to get the name property specified in the form. It
> is working code,
> I just want to ask if this is the best appraoch in
> struts application?
>
>
> Please advise. thanks!!
>
>
> register.jsp
> =============
> <html:form action="register.do">
> <P>Name: <html:text property="name"></html:text>
> <P>Address: <html:text
> property="address"></html:text>
> <P>ZIP: <html:text property="zip"></html:text>
> <html:submit>Register Online</html:submit>
> </html:form>
>
>
> result.jsp
> ==========
> <H3>Name = <%= request.getParameter("name") %></H3>
>
>
> struts-config.xml
> =================
> <action-mappings>
> <action name="registerFormBean" path="/register"
> scope="request"
> type="com.insights.struts.actions.RegisterAction"
> input="register.jsp">
> <forward name="success" path="/result.jsp"/>
> </action>
> </action-mappings>
>
>
> RegisterAction.java
> ===================
>
> public ActionForward execute(...)
> {
> //etc...
> forward = mapping.findForward("success");
> }
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
>
>
__________________________________
Discover Yahoo!
Stay in touch with email, IM, photo sharing and more. Check it out!
http://discover.yahoo.com/stayintouch.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: My IncludeAction-where to forward
Posted by Martin Gainty <mg...@hotmail.com>.
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" <hu...@ix.netcom.com>
To: "Struts Users Mailing List" <us...@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:quickcur@yahoo.com]
> 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: My IncludeAction-where to forward
Posted by "David G. Friedman" <hu...@ix.netcom.com>.
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:quickcur@yahoo.com]
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org