Re: Passing Parameters Between Actions
Is there any reason you are forwarding from JSP? Try using Dispatcher in Action1 class like request.getRequestDispatcher(/Action2.do).forward(request, response); - jung Hunter Hillegas wrote: I am trying to pass a parameter between two actions and running into trouble. I call action 1 like this: /Action1.do?rec_num=1 Action1 does some processing and when complete it forwards via an ActionForward to Action2 as such: forward name=action2 path=/Action2.do/ Action2 has no way to retrieve the parameter originally passed in to the first action, rec_num. When I try to grab it using request.getParameter() I get a NPE. I also tried setting it as a request attribute and that didn't work. Session might work but I am trying not use sessions. Any ideas on what I can do? Thanks, Hunter - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Passing Parameters Between Actions
snip Is there any reason you are forwarding from JSP? /snip JSP where got? He stated quite clearly he is forwarding from one action to another using (returning I presume) an ActionForward. snip forward name=action2 path=/Action2.do/ /snip I was going to suggest that you specify redirect=false in the forward, but looking at the javadoc it seems that that is the default already! Hmm.. Try it anyway and see if it works as it sounds very much like your doing a client side redirect :-) If it really is doing a server side redirect you should still be able to get at that parameter - the only situation I can think of where you would get these symtoms is if its a multipart request and the first action has an actionform associated with it and the second does not. (If if that parameter is due to some other request wrapper implementation). That doesnt explain the attributes not working though. It really does sound like your doing a client side redirect. Hmmm... just checked the source and its definately default to redirect=false. Ok, I give in... btw: its considered bad practice to chain actions in this manner. Search the archive to find out why... -Original Message- From: Jung Yang [mailto:[EMAIL PROTECTED] Sent: Tuesday, 15 July 2003 22:31 To: [EMAIL PROTECTED] Subject: Re: Passing Parameters Between Actions Is there any reason you are forwarding from JSP? Try using Dispatcher in Action1 class like request.getRequestDispatcher(/Action2.do).forward(request, response); - jung Hunter Hillegas wrote: I am trying to pass a parameter between two actions and running into trouble. I call action 1 like this: /Action1.do?rec_num=1 Action1 does some processing and when complete it forwards via an ActionForward to Action2 as such: forward name=action2 path=/Action2.do/ Action2 has no way to retrieve the parameter originally passed in to the first action, rec_num. When I try to grab it using request.getParameter() I get a NPE. I also tried setting it as a request attribute and that didn't work. Session might work but I am trying not use sessions. Any ideas on what I can do? Thanks, Hunter - 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]
RE: Passing Parameters Between Actions
it won't . It look in the config file to get mapping.findForward(FOR_WARD)...thats all..then it will append the attribute to it. It work's for me -Original Message- From: Hunter Hillegas [mailto:[EMAIL PROTECTED] Sent: Monday, July 07, 2003 6:32 PM To: Struts List Subject: Re: Passing Parameters Between Actions Won't this look for a forward with '?rec_num=map1' in the name of the forward? This is not what I need... I need to make the parameter available to the second action... But the parameter will change with each request. I can't hardwire the parameter names into the forward names. Hunter From: Mathew, Manoj [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Mon, 7 Jul 2003 15:49:59 -0500 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: RE: Passing Parameters Between Actions or u can use in action1: actionForward = mapping.findForward(FOR_WARD) + ?rec_num=map1; -Original Message- From: Mathew, Manoj Sent: Monday, July 07, 2003 3:34 PM To: Struts Users Mailing List Subject: RE: Passing Parameters Between Actions path=/Action2.do?rec_num=map1 / request.getParameter(rec_num); can use logic:equal if you are forwarding to a JSP -Original Message- From: Hunter Hillegas [mailto:[EMAIL PROTECTED] Sent: Monday, July 07, 2003 3:03 PM To: Struts List Subject: Passing Parameters Between Actions I am trying to pass a parameter between two actions and running into trouble. I call action 1 like this: /Action1.do?rec_num=1 Action1 does some processing and when complete it forwards via an ActionForward to Action2 as such: forward name=action2 path=/Action2.do/ Action2 has no way to retrieve the parameter originally passed in to the first action, rec_num. When I try to grab it using request.getParameter() I get a NPE. I also tried setting it as a request attribute and that didn't work. Session might work but I am trying not use sessions. Any ideas on what I can do? Thanks, Hunter - 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] - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Passing Parameters Between Actions
path=/Action2.do?rec_num=map1 / request.getParameter(rec_num); can use logic:equal if you are forwarding to a JSP -Original Message- From: Hunter Hillegas [mailto:[EMAIL PROTECTED] Sent: Monday, July 07, 2003 3:03 PM To: Struts List Subject: Passing Parameters Between Actions I am trying to pass a parameter between two actions and running into trouble. I call action 1 like this: /Action1.do?rec_num=1 Action1 does some processing and when complete it forwards via an ActionForward to Action2 as such: forward name=action2 path=/Action2.do/ Action2 has no way to retrieve the parameter originally passed in to the first action, rec_num. When I try to grab it using request.getParameter() I get a NPE. I also tried setting it as a request attribute and that didn't work. Session might work but I am trying not use sessions. Any ideas on what I can do? Thanks, Hunter - 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]
RE: Passing Parameters Between Actions
or u can use in action1: actionForward = mapping.findForward(FOR_WARD) + ?rec_num=map1; -Original Message- From: Mathew, Manoj Sent: Monday, July 07, 2003 3:34 PM To: Struts Users Mailing List Subject: RE: Passing Parameters Between Actions path=/Action2.do?rec_num=map1 / request.getParameter(rec_num); can use logic:equal if you are forwarding to a JSP -Original Message- From: Hunter Hillegas [mailto:[EMAIL PROTECTED] Sent: Monday, July 07, 2003 3:03 PM To: Struts List Subject: Passing Parameters Between Actions I am trying to pass a parameter between two actions and running into trouble. I call action 1 like this: /Action1.do?rec_num=1 Action1 does some processing and when complete it forwards via an ActionForward to Action2 as such: forward name=action2 path=/Action2.do/ Action2 has no way to retrieve the parameter originally passed in to the first action, rec_num. When I try to grab it using request.getParameter() I get a NPE. I also tried setting it as a request attribute and that didn't work. Session might work but I am trying not use sessions. Any ideas on what I can do? Thanks, Hunter - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Passing Parameters Between Actions
Won't this look for a forward with '?rec_num=map1' in the name of the forward? This is not what I need... I need to make the parameter available to the second action... But the parameter will change with each request. I can't hardwire the parameter names into the forward names. Hunter From: Mathew, Manoj [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Mon, 7 Jul 2003 15:49:59 -0500 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: RE: Passing Parameters Between Actions or u can use in action1: actionForward = mapping.findForward(FOR_WARD) + ?rec_num=map1; -Original Message- From: Mathew, Manoj Sent: Monday, July 07, 2003 3:34 PM To: Struts Users Mailing List Subject: RE: Passing Parameters Between Actions path=/Action2.do?rec_num=map1 / request.getParameter(rec_num); can use logic:equal if you are forwarding to a JSP -Original Message- From: Hunter Hillegas [mailto:[EMAIL PROTECTED] Sent: Monday, July 07, 2003 3:03 PM To: Struts List Subject: Passing Parameters Between Actions I am trying to pass a parameter between two actions and running into trouble. I call action 1 like this: /Action1.do?rec_num=1 Action1 does some processing and when complete it forwards via an ActionForward to Action2 as such: forward name=action2 path=/Action2.do/ Action2 has no way to retrieve the parameter originally passed in to the first action, rec_num. When I try to grab it using request.getParameter() I get a NPE. I also tried setting it as a request attribute and that didn't work. Session might work but I am trying not use sessions. Any ideas on what I can do? Thanks, Hunter - 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] - 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]
RE: Passing parameters to Actions
parameter is only used for dispatch actions. If you want to set properties for an action... you can extend the ActionMapping class and use the set-property in an action element while specifying the className attribute of the action element. Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Sloan Seaman [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:29 PM To: Struts Users Mailing List Subject: Passing parameters to Actions In the struts-config.xml file I want to pass a few parameters to my actions but it looks like the DTD only supports one parameter tag. I.E.: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main parameter=admin forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ /action When I would rather do something like: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ parameter name=ROLES_ALLOWED value=admin/ /action Now, I know there is a roles attribute but we are doing out own security model and are not using request.isUserInRole(). (BTW: is there any way to write to whatever request.isUserInRole() used to do its lookup so we can use it?) Is there any way to have parameters passed like how I would like? I could spoof forward to something like forward name=ROLES_ALLOWED path=admin/ but I would rather not. Thanks! -- Sloan - 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]
RE: Passing parameters to Actions
Have looked at extending ActionConfig? You could add a field for assigning roles. If you wanted to allow more than one, it would let you do: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ set-property property=addRole value=admin/ set-property property=addRole value=superuser/ /action The rest is really up to you. Just giving you some ideas. -- James Mitchell Software Engineer/Struts Evangelist -Original Message- From: Sloan Seaman [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 2:29 PM To: Struts Users Mailing List Subject: Passing parameters to Actions In the struts-config.xml file I want to pass a few parameters to my actions but it looks like the DTD only supports one parameter tag. I.E.: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main parameter=admin forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ /action When I would rather do something like: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ parameter name=ROLES_ALLOWED value=admin/ /action Now, I know there is a roles attribute but we are doing out own security model and are not using request.isUserInRole(). (BTW: is there any way to write to whatever request.isUserInRole() used to do its lookup so we can use it?) Is there any way to have parameters passed like how I would like? I could spoof forward to something like forward name=ROLES_ALLOWED path=admin/ but I would rather not. Thanks! -- Sloan - 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]
RE: Passing parameters to Actions
Here is a config sample: action path=/myAction.do parameter=submit type=com.foo.MyAction name=myForm scope=request className=com.foo.MyExtendedActionMapping set-property property=xxx value=yyy/ forward name=success path=here.jsp redirect=false/ forward name=fail path=there.jsp redirect=true/ /action Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Brandon Goodin [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:33 PM To: Struts Users Mailing List Subject: RE: Passing parameters to Actions parameter is only used for dispatch actions. If you want to set properties for an action... you can extend the ActionMapping class and use the set-property in an action element while specifying the className attribute of the action element. Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Sloan Seaman [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:29 PM To: Struts Users Mailing List Subject: Passing parameters to Actions In the struts-config.xml file I want to pass a few parameters to my actions but it looks like the DTD only supports one parameter tag. I.E.: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main parameter=admin forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ /action When I would rather do something like: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ parameter name=ROLES_ALLOWED value=admin/ /action Now, I know there is a roles attribute but we are doing out own security model and are not using request.isUserInRole(). (BTW: is there any way to write to whatever request.isUserInRole() used to do its lookup so we can use it?) Is there any way to have parameters passed like how I would like? I could spoof forward to something like forward name=ROLES_ALLOWED path=admin/ but I would rather not. Thanks! -- Sloan - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Passing parameters to Actions
parameter is also used for ForwardAction. Actually, any action can access its parameter using mapping.getParameter() and use it however it wants. We do this in several actions. From the ActionConfig javadoc: parameter protected java.lang.String parameter General purpose configuration parameter that can be used to pass extra iunformation to the Action instance selected by this Action. Struts does not itself use this value in any way. However, Sloan, you ar right that it is limited to passing one parameter and that the parameter's intended use is unclear if it is simply called parameter. Brandon's solution to subclass ActionMapping is probably the best (only reasonable?) alternative. Derek Richardson -Original Message- From: Brandon Goodin [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 2:33 PM To: Struts Users Mailing List Subject: RE: Passing parameters to Actions parameter is only used for dispatch actions. If you want to set properties for an action... you can extend the ActionMapping class and use the set-property in an action element while specifying the className attribute of the action element. Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Sloan Seaman [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:29 PM To: Struts Users Mailing List Subject: Passing parameters to Actions In the struts-config.xml file I want to pass a few parameters to my actions but it looks like the DTD only supports one parameter tag. I.E.: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main parameter=admin forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ /action When I would rather do something like: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ parameter name=ROLES_ALLOWED value=admin/ /action Now, I know there is a roles attribute but we are doing out own security model and are not using request.isUserInRole(). (BTW: is there any way to write to whatever request.isUserInRole() used to do its lookup so we can use it?) Is there any way to have parameters passed like how I would like? I could spoof forward to something like forward name=ROLES_ALLOWED path=admin/ but I would rather not. Thanks! -- Sloan - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Passing parameters to Actions
It may be easier for you to extend RequestProcessor and override processRoles(...) and perform your own authorization there. I started down that road, but didn't like the effect of return false from processRoles, so we always return true and do the real role checking in our base action class (mapping.getRoleNames() gives us the value of the roles attribute) so that we can return mapping.getInputForward() when the role check fails... -- Voytek Jarnot Quidquid latine dictum sit, altum viditur. -Original Message- From: Sloan Seaman [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 2:29 PM To: Struts Users Mailing List Subject: Passing parameters to Actions In the struts-config.xml file I want to pass a few parameters to my actions but it looks like the DTD only supports one parameter tag. I.E.: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main parameter=admin forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ /action When I would rather do something like: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ parameter name=ROLES_ALLOWED value=admin/ /action Now, I know there is a roles attribute but we are doing out own security model and are not using request.isUserInRole(). (BTW: is there any way to write to whatever request.isUserInRole() used to do its lookup so we can use it?) Is there any way to have parameters passed like how I would like? I could spoof forward to something like forward name=ROLES_ALLOWED path=admin/ but I would rather not. Thanks! -- Sloan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Passing parameters to Actions
Ok. sounds like a plan. Question though: How do I access the set-property information? Do I have to parse the XML or something? Sorry... I'm a bit new to Struts... -- Sloan - Original Message - From: Brandon Goodin [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 2:40 PM Subject: RE: Passing parameters to Actions Here is a config sample: action path=/myAction.do parameter=submit type=com.foo.MyAction name=myForm scope=request className=com.foo.MyExtendedActionMapping set-property property=xxx value=yyy/ forward name=success path=here.jsp redirect=false/ forward name=fail path=there.jsp redirect=true/ /action Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Brandon Goodin [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:33 PM To: Struts Users Mailing List Subject: RE: Passing parameters to Actions parameter is only used for dispatch actions. If you want to set properties for an action... you can extend the ActionMapping class and use the set-property in an action element while specifying the className attribute of the action element. Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Sloan Seaman [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:29 PM To: Struts Users Mailing List Subject: Passing parameters to Actions In the struts-config.xml file I want to pass a few parameters to my actions but it looks like the DTD only supports one parameter tag. I.E.: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main parameter=admin forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ /action When I would rather do something like: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ parameter name=ROLES_ALLOWED value=admin/ /action Now, I know there is a roles attribute but we are doing out own security model and are not using request.isUserInRole(). (BTW: is there any way to write to whatever request.isUserInRole() used to do its lookup so we can use it?) Is there any way to have parameters passed like how I would like? I could spoof forward to something like forward name=ROLES_ALLOWED path=admin/ but I would rather not. Thanks! -- Sloan - 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] - 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]
RE: Passing parameters to Actions
It is done automagically upon startup of your application. When struts processes it's config (struts-config.xml) it generates ActionMapping instances for each action. When you specify your extended ActionMapping in the className attribute of action struts will populate the related property or properties of that class. Your extended Action mapping must have matching getter/setter properties that match you property= value (i.e. set-property property=aProperty value=aValue/ relates to public setAProperty(String aValue){};) One of the issues you might run into is that you cant easily change the properties during runtime. If you make role changes to the Action you will have to reboot the webapp. This is usually not a major deal. Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Sloan Seaman [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:56 PM To: Struts Users Mailing List Subject: Re: Passing parameters to Actions Ok. sounds like a plan. Question though: How do I access the set-property information? Do I have to parse the XML or something? Sorry... I'm a bit new to Struts... -- Sloan - Original Message - From: Brandon Goodin [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 2:40 PM Subject: RE: Passing parameters to Actions Here is a config sample: action path=/myAction.do parameter=submit type=com.foo.MyAction name=myForm scope=request className=com.foo.MyExtendedActionMapping set-property property=xxx value=yyy/ forward name=success path=here.jsp redirect=false/ forward name=fail path=there.jsp redirect=true/ /action Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Brandon Goodin [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:33 PM To: Struts Users Mailing List Subject: RE: Passing parameters to Actions parameter is only used for dispatch actions. If you want to set properties for an action... you can extend the ActionMapping class and use the set-property in an action element while specifying the className attribute of the action element. Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Sloan Seaman [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:29 PM To: Struts Users Mailing List Subject: Passing parameters to Actions In the struts-config.xml file I want to pass a few parameters to my actions but it looks like the DTD only supports one parameter tag. I.E.: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main parameter=admin forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ /action When I would rather do something like: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ parameter name=ROLES_ALLOWED value=admin/ /action Now, I know there is a roles attribute but we are doing out own security model and are not using request.isUserInRole(). (BTW: is there any way to write to whatever request.isUserInRole() used to do its lookup so we can use it?) Is there any way to have parameters passed like how I would like? I could spoof forward to something like forward name=ROLES_ALLOWED path=admin/ but I would rather not. Thanks! -- Sloan - 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] - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Passing parameters to Actions
Very cool. Thanks!!! -- Sloan - Original Message - From: Brandon Goodin [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:06 PM Subject: RE: Passing parameters to Actions It is done automagically upon startup of your application. When struts processes it's config (struts-config.xml) it generates ActionMapping instances for each action. When you specify your extended ActionMapping in the className attribute of action struts will populate the related property or properties of that class. Your extended Action mapping must have matching getter/setter properties that match you property= value (i.e. set-property property=aProperty value=aValue/ relates to public setAProperty(String aValue){};) One of the issues you might run into is that you cant easily change the properties during runtime. If you make role changes to the Action you will have to reboot the webapp. This is usually not a major deal. Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Sloan Seaman [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:56 PM To: Struts Users Mailing List Subject: Re: Passing parameters to Actions Ok. sounds like a plan. Question though: How do I access the set-property information? Do I have to parse the XML or something? Sorry... I'm a bit new to Struts... -- Sloan - Original Message - From: Brandon Goodin [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 2:40 PM Subject: RE: Passing parameters to Actions Here is a config sample: action path=/myAction.do parameter=submit type=com.foo.MyAction name=myForm scope=request className=com.foo.MyExtendedActionMapping set-property property=xxx value=yyy/ forward name=success path=here.jsp redirect=false/ forward name=fail path=there.jsp redirect=true/ /action Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Brandon Goodin [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:33 PM To: Struts Users Mailing List Subject: RE: Passing parameters to Actions parameter is only used for dispatch actions. If you want to set properties for an action... you can extend the ActionMapping class and use the set-property in an action element while specifying the className attribute of the action element. Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Sloan Seaman [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:29 PM To: Struts Users Mailing List Subject: Passing parameters to Actions In the struts-config.xml file I want to pass a few parameters to my actions but it looks like the DTD only supports one parameter tag. I.E.: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main parameter=admin forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ /action When I would rather do something like: action path=/app/main type=com.symbol.mobilecommerce.analysis.actions.app.Main name=app.main forward name=PAGE_SRC path=/app/main.jsp/ forward name=PAGE_ACCESS_DENIED path=/index.jsp/ parameter name=ROLES_ALLOWED value=admin/ /action Now, I know there is a roles attribute but we are doing out own security model and are not using request.isUserInRole(). (BTW: is there any way to write to whatever request.isUserInRole() used to do its lookup so we can use it?) Is there any way to have parameters passed like how I would like? I could spoof forward to something like forward name=ROLES_ALLOWED path=admin/ but I would rather not. Thanks! -- Sloan - 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] - 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
RE: Passing parameters to Actions
I wonder if MyExtendedActionMapping is as simple as: public class MyExtendedActionMapping extends ActionMapping { private String xxx; public void setXXX(String xxx) { this.xxx = xxx; } public String getXXX() { return xxx; } } Should I implement any other method...? Thanks. Guido García Bernardo [EMAIL PROTECTED] Spain is different. On Tue, 25 Feb 2003, Brandon Goodin wrote: } Here is a config sample: } } action path=/myAction.do }parameter=submit }type=com.foo.MyAction }name=myForm }scope=request }className=com.foo.MyExtendedActionMapping } set-property property=xxx value=yyy/ } forward name=success path=here.jsp redirect=false/ } forward name=fail path=there.jsp redirect=true/ } /action - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Passing parameters to Actions
maybe a super() call in the constructor. But you shouldn't need anymore than that. Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Guido [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 1:32 PM To: Struts Users Mailing List Subject: RE: Passing parameters to Actions I wonder if MyExtendedActionMapping is as simple as: public class MyExtendedActionMapping extends ActionMapping { private String xxx; public void setXXX(String xxx) { this.xxx = xxx; } public String getXXX() { return xxx; } } Should I implement any other method...? Thanks. Guido García Bernardo [EMAIL PROTECTED] Spain is different. On Tue, 25 Feb 2003, Brandon Goodin wrote: } Here is a config sample: } } action path=/myAction.do }parameter=submit }type=com.foo.MyAction }name=myForm }scope=request }className=com.foo.MyExtendedActionMapping } set-property property=xxx value=yyy/ } forward name=success path=here.jsp redirect=false/ } forward name=fail path=there.jsp redirect=true/ } /action - 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]
RE: Passing parameters to Actions
No, that's it. 1. Make your class extending o.a.s.a.ActionMapping 2. Add className=my.package.MyActionMapping to your action 3. Add your set-property property=xxx value=Whooo hooo!!!/ -- James Mitchell Software Engineer/Struts Evangelist -Original Message- From: Guido [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:32 PM To: Struts Users Mailing List Subject: RE: Passing parameters to Actions I wonder if MyExtendedActionMapping is as simple as: public class MyExtendedActionMapping extends ActionMapping { private String xxx; public void setXXX(String xxx) { this.xxx = xxx; } public String getXXX() { return xxx; } } Should I implement any other method...? Thanks. Guido García Bernardo [EMAIL PROTECTED] Spain is different. On Tue, 25 Feb 2003, Brandon Goodin wrote: } Here is a config sample: } } action path=/myAction.do } parameter=submit } type=com.foo.MyAction } name=myForm } scope=request } className=com.foo.MyExtendedActionMapping } set-property property=xxx value=yyy/ } forward name=success path=here.jsp redirect=false/ } forward name=fail path=there.jsp redirect=true/ } /action - 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]
Re: Passing parameters to Actions
Well, I'm sure it's a typo, but make sure the methods are called setXxx(String) and getXxx()..! :) Geeta Guido wrote: I wonder if MyExtendedActionMapping is as simple as: public class MyExtendedActionMapping extends ActionMapping { private String xxx; public void setXXX(String xxx) { this.xxx = xxx; } public String getXXX() { return xxx; } } Should I implement any other method...? Thanks. Guido García Bernardo [EMAIL PROTECTED] Spain is different. On Tue, 25 Feb 2003, Brandon Goodin wrote: } Here is a config sample: } } action path=/myAction.do }parameter=submit }type=com.foo.MyAction }name=myForm }scope=request }className=com.foo.MyExtendedActionMapping } set-property property=xxx value=yyy/ } forward name=success path=here.jsp redirect=false/ } forward name=fail path=there.jsp redirect=true/ } /action - 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]
RE: Passing parameters to Actions
good eye Geeta :-D Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Geeta Ramani [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 1:39 PM To: Struts Users Mailing List Subject: Re: Passing parameters to Actions Well, I'm sure it's a typo, but make sure the methods are called setXxx(String) and getXxx()..! :) Geeta Guido wrote: I wonder if MyExtendedActionMapping is as simple as: public class MyExtendedActionMapping extends ActionMapping { private String xxx; public void setXXX(String xxx) { this.xxx = xxx; } public String getXXX() { return xxx; } } Should I implement any other method...? Thanks. Guido García Bernardo [EMAIL PROTECTED] Spain is different. On Tue, 25 Feb 2003, Brandon Goodin wrote: } Here is a config sample: } } action path=/myAction.do }parameter=submit }type=com.foo.MyAction }name=myForm }scope=request }className=com.foo.MyExtendedActionMapping } set-property property=xxx value=yyy/ } forward name=success path=here.jsp redirect=false/ } forward name=fail path=there.jsp redirect=true/ } /action - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Passing parameters to Actions
No need for that either since the superclass constructor is implicitly called. At 01:38 PM 2/25/2003 -0700, you wrote: maybe a super() call in the constructor. But you shouldn't need anymore than that. Brandon Goodin Phase Web and Multimedia PO Box 85 Whitefish MT 59937 P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Guido [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 1:32 PM To: Struts Users Mailing List Subject: RE: Passing parameters to Actions I wonder if MyExtendedActionMapping is as simple as: public class MyExtendedActionMapping extends ActionMapping { private String xxx; public void setXXX(String xxx) { this.xxx = xxx; } public String getXXX() { return xxx; } } Should I implement any other method...? Thanks. Guido García Bernardo [EMAIL PROTECTED] Spain is different. On Tue, 25 Feb 2003, Brandon Goodin wrote: } Here is a config sample: } } action path=/myAction.do }parameter=submit }type=com.foo.MyAction }name=myForm }scope=request }className=com.foo.MyExtendedActionMapping } set-property property=xxx value=yyy/ } forward name=success path=here.jsp redirect=false/ } forward name=fail path=there.jsp redirect=true/ } /action - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]