Re: Passing Parameters from Action to JSP's
You should use an ActionForm to store parameters. Your hidden fields can get the value from the request like this: %-- hidden field (mode is one of create, edit, or view) --% html-el:hidden property=myParameter value=${requestScope.myForm.myParameter}/ Of course there are other ways to do it but once you have more than your two params you won't want to be juggling them around on the request Struts even puts the form on the request for you so you don't have to do it yourself. Hope that helps Samanth Athrey [EMAIL PROTECTED] 10/12/2003 04:11 PM Please respond to Struts Users Mailing List To: [EMAIL PROTECTED] cc: Subject:Passing Parameters from Action to JSP's Hello All, I have a issue here. Any help would be of great help. I have an action class - Action_A which forwards the request to A.jsp. A.jsp has 2 query parameters that are displayed correctly. The two parameters are stored in hidden variables within the form tag. Now, when this page is submitted, it calls Action_B which again forwards the request back to A.jsp. But this time, the query parameters are lost! Is there a way to send these two parameters from the Action class back to JSP? Is it legal to do something like this? Or is there a better way to achive this.? Regards Sam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Passing Parameters from Action to JSP's
hi Sam IS your form associated with both of the Actions. - Original Message - From: Samanth Athrey [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, December 10, 2003 10:41 AM Subject: Passing Parameters from Action to JSP's Hello All, I have a issue here. Any help would be of great help. I have an action class - Action_A which forwards the request to A.jsp. A.jsp has 2 query parameters that are displayed correctly. The two parameters are stored in hidden variables within the form tag. Now, when this page is submitted, it calls Action_B which again forwards the request back to A.jsp. But this time, the query parameters are lost! Is there a way to send these two parameters from the Action class back to JSP? Is it legal to do something like this? Or is there a better way to achive this.? Regards Sam - 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 forms
Carey, Thanks for your mail. I knew about the option you suggested and mentioned it in my mail. quote: I know I can save the foo attribute into session in Action A class and access it in Action B, or set the scope of Form A to session in struts-config and access Form A from Action B. unquote: However, the disadvantage of this option is that I need to use session scope for the forms, which I would like to avoid. I also know it is possible to pass the form attribute as a request parameter as follows: html:link page=Action B?parameter=value But, this allows the user to see the parameters being passed. I would rather use buttons for the link and post the form. Do you have any suggestions/comments? Thanks, Shyam --- Carey Nation [EMAIL PROTECTED] wrote: I have some vague memory (perhaps completely wrong) that the forms are stored wherever they are stored using the names that you specify in struts-config. It may not be the nicest way to do this, but I'm pretty sure that, given session scope on your forms, you can do something like (FormA)forma = session.getAttribute(FormA); HTH, Carey - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Passing parameters between forms
My preference is to emulate the session functionality in your own classes, i.e. publish / subscribe. Stick a static map in your class and use a unique key generated from objects both threads are aware of to index the object, then you can pull it out when you need to. Synchronize if you need to as well. I like this better because then you can run junit tests w/o worring about the container. Edgar -Original Message- From: Shyam A [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 14, 2003 8:39 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: Passing parameters between forms Carey, Thanks for your mail. I knew about the option you suggested and mentioned it in my mail. quote: I know I can save the foo attribute into session in Action A class and access it in Action B, or set the scope of Form A to session in struts-config and access Form A from Action B. unquote: However, the disadvantage of this option is that I need to use session scope for the forms, which I would like to avoid. I also know it is possible to pass the form attribute as a request parameter as follows: html:link page=Action B?parameter=value But, this allows the user to see the parameters being passed. I would rather use buttons for the link and post the form. Do you have any suggestions/comments? Thanks, Shyam --- Carey Nation [EMAIL PROTECTED] wrote: I have some vague memory (perhaps completely wrong) that the forms are stored wherever they are stored using the names that you specify in struts-config. It may not be the nicest way to do this, but I'm pretty sure that, given session scope on your forms, you can do something like (FormA)forma = session.getAttribute(FormA); HTH, Carey - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Passing parameters between forms
This approach might work for a small system, but I would not encourage it for a large business app. If I follow you correctly, this assumes that subsequent pages will be served by the same container. This is infrequently (at least in systems I've seen) the case... -Original Message- From: Edgar P Dollin [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 14, 2003 10:19 AM To: 'Shyam A'; [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: Passing parameters between forms My preference is to emulate the session functionality in your own classes, i.e. publish / subscribe. Stick a static map in your class and use a unique key generated from objects both threads are aware of to index the object, then you can pull it out when you need to. Synchronize if you need to as well. I like this better because then you can run junit tests w/o worring about the container. Edgar -Original Message- From: Shyam A [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 14, 2003 8:39 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: Passing parameters between forms Carey, Thanks for your mail. I knew about the option you suggested and mentioned it in my mail. quote: I know I can save the foo attribute into session in Action A class and access it in Action B, or set the scope of Form A to session in struts-config and access Form A from Action B. unquote: However, the disadvantage of this option is that I need to use session scope for the forms, which I would like to avoid. I also know it is possible to pass the form attribute as a request parameter as follows: html:link page=Action B?parameter=value But, this allows the user to see the parameters being passed. I would rather use buttons for the link and post the form. Do you have any suggestions/comments? Thanks, Shyam --- Carey Nation [EMAIL PROTECTED] wrote: I have some vague memory (perhaps completely wrong) that the forms are stored wherever they are stored using the names that you specify in struts-config. It may not be the nicest way to do this, but I'm pretty sure that, given session scope on your forms, you can do something like (FormA)forma = session.getAttribute(FormA); HTH, Carey - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - 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 forms
Hi Shyam, If you change html:text property=foo/ to html:hidden property=foo write=true/ OR if you just add html:hidden property=foo/ does it work? Susan Bradeen On 10/13/2003 08:27:41 PM Shyam A wrote: Hi, I have a scenario where I need to pass parameters between forms.i.e, I have two forms, Form A and Form B with the same attribute foo. The value of foo is set in Form A. Also, I have a link from the JSP page corresponding to Form A to the action corresponding to Form B,i.e, In form A, I have html:form action=/Action A html:text property=foo/ ... html:link forward=Action B bean:message key=key/ /html:link /html:form I'm unable to access the foo property in Action B class using String foo = ((Form B) form).getFoo() as foo is not in scope. I know I can save the foo attribute into session in Action A class and access it in Action B, or set the scope of Form A to session in struts-config and access Form A from Action B. Is there a better way to do this? Any help/suggestions would be greatly appreciated. Thanks, Shyam __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - 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 forms
I have some vague memory (perhaps completely wrong) that the forms are stored wherever they are stored using the names that you specify in struts-config. It may not be the nicest way to do this, but I'm pretty sure that, given session scope on your forms, you can do something like (FormA)forma = session.getAttribute(FormA); HTH, Carey - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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 or object from one action to other
Isn't this just action chaining using HTTP instead of within the jvm? I'm not sure I get the reasons why action chaining is inherently a bad idea, though I do get that there are potential pitfalls if misused, but that's true of many patterns. Can you explain? Or point me to an article that explains? Thanks. Andrew Hill wrote: (Oops. Hit send too soon. Try again!) You can put them in the request as attributes and use a non-redirecting forward *but* then you are 'action chaining'. (Action chains are bad. n'kay) The other alternative - suitable for string parameters - is to make them request parameters by appending to the url. To do this you create a new forward based on the existing forward. ie in your action: ActionForward forward = mapping.findForward(myforward); forward = new ctionForward( addParameterToUrl(forward.getPath(),foo,bar), forward.getRedirect() ); return forward; where addParameterToUrl does something like: private String addParameterToURL(String url, String parameter, String value) { return url + ( (url.indexOf(?)==-1) ? ? : ) + parameter + = + value; } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, 5 June 2003 19:25 To: [EMAIL PROTECTED] Subject: passing parameters or object from one action to other hi all, I have an action1 whose forward is another action2. I need to pass some parameters or object from action1 to action2 I don't want to put them(parameters or object) in the session. Is there a solution for doing that. thanks in advance Meissa L'integrite de ce message n'etant pas assuree sur internet, Natexis Banques Populaires ne peut etre tenu responsable de son contenu. Toute utilisation ou diffusion non autorisee est interdite. Si vous n'etes pas destinataire de ce message, merci de le detruire et d'avertir l'expediteur. The integrity of this message cannot be guaranteed on the Internet. Natexis Banques Populaires can not therefore be considered responsible for the contents.Any unauthorized use or dissemination is prohibited. If you are not the intended recipient of this message, then please delete it and notify the sender. - 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 or object from one action to other
If you take a quick look through the archives you will see it has been discussed quite a bit not all that long ago. -Original Message- From: David Chelimsky [mailto:[EMAIL PROTECTED] Sent: Thursday, 5 June 2003 20:59 To: Struts Users Mailing List Subject: Re: passing parameters or object from one action to other Isn't this just action chaining using HTTP instead of within the jvm? I'm not sure I get the reasons why action chaining is inherently a bad idea, though I do get that there are potential pitfalls if misused, but that's true of many patterns. Can you explain? Or point me to an article that explains? Thanks. Andrew Hill wrote: (Oops. Hit send too soon. Try again!) You can put them in the request as attributes and use a non-redirecting forward *but* then you are 'action chaining'. (Action chains are bad. n'kay) The other alternative - suitable for string parameters - is to make them request parameters by appending to the url. To do this you create a new forward based on the existing forward. ie in your action: ActionForward forward = mapping.findForward(myforward); forward = new ctionForward( addParameterToUrl(forward.getPath(),foo,bar), forward.getRedirect() ); return forward; where addParameterToUrl does something like: private String addParameterToURL(String url, String parameter, String value) { return url + ( (url.indexOf(?)==-1) ? ? : ) + parameter + = + value; } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, 5 June 2003 19:25 To: [EMAIL PROTECTED] Subject: passing parameters or object from one action to other hi all, I have an action1 whose forward is another action2. I need to pass some parameters or object from action1 to action2 I don't want to put them(parameters or object) in the session. Is there a solution for doing that. thanks in advance Meissa L'integrite de ce message n'etant pas assuree sur internet, Natexis Banques Populaires ne peut etre tenu responsable de son contenu. Toute utilisation ou diffusion non autorisee est interdite. Si vous n'etes pas destinataire de ce message, merci de le detruire et d'avertir l'expediteur. The integrity of this message cannot be guaranteed on the Internet. Natexis Banques Populaires can not therefore be considered responsible for the contents.Any unauthorized use or dissemination is prohibited. If you are not the intended recipient of this message, then please delete it and notify the sender. - 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 or object from one action to other
You can put them in the request as attributes and use a non-redirecting forward *but* then you are 'action chaining'. (Action chains are bad. n'kay) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, 5 June 2003 19:25 To: [EMAIL PROTECTED] Subject: passing parameters or object from one action to other hi all, I have an action1 whose forward is another action2. I need to pass some parameters or object from action1 to action2 I don't want to put them(parameters or object) in the session. Is there a solution for doing that. thanks in advance Meissa L'integrite de ce message n'etant pas assuree sur internet, Natexis Banques Populaires ne peut etre tenu responsable de son contenu. Toute utilisation ou diffusion non autorisee est interdite. Si vous n'etes pas destinataire de ce message, merci de le detruire et d'avertir l'expediteur. The integrity of this message cannot be guaranteed on the Internet. Natexis Banques Populaires can not therefore be considered responsible for the contents.Any unauthorized use or dissemination is prohibited. If you are not the intended recipient of this message, then please delete it and notify the sender. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: passing parameters or object from one action to other
(Oops. Hit send too soon. Try again!) You can put them in the request as attributes and use a non-redirecting forward *but* then you are 'action chaining'. (Action chains are bad. n'kay) The other alternative - suitable for string parameters - is to make them request parameters by appending to the url. To do this you create a new forward based on the existing forward. ie in your action: ActionForward forward = mapping.findForward(myforward); forward = new ctionForward( addParameterToUrl(forward.getPath(),foo,bar), forward.getRedirect() ); return forward; where addParameterToUrl does something like: private String addParameterToURL(String url, String parameter, String value) { return url + ( (url.indexOf(?)==-1) ? ? : ) + parameter + = + value; } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, 5 June 2003 19:25 To: [EMAIL PROTECTED] Subject: passing parameters or object from one action to other hi all, I have an action1 whose forward is another action2. I need to pass some parameters or object from action1 to action2 I don't want to put them(parameters or object) in the session. Is there a solution for doing that. thanks in advance Meissa L'integrite de ce message n'etant pas assuree sur internet, Natexis Banques Populaires ne peut etre tenu responsable de son contenu. Toute utilisation ou diffusion non autorisee est interdite. Si vous n'etes pas destinataire de ce message, merci de le detruire et d'avertir l'expediteur. The integrity of this message cannot be guaranteed on the Internet. Natexis Banques Populaires can not therefore be considered responsible for the contents.Any unauthorized use or dissemination is prohibited. If you are not the intended recipient of this message, then please delete it and notify the sender. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Réf. : RE: passing parameters or object from oneaction to other
why do you say 'Action chains are bad'. Is there another solution then. Meissa Andrew Hill [EMAIL PROTECTED] 05/06/2003 13:28 Veuillez répondre à Struts Users Mailing List Pour : Struts Users Mailing List [EMAIL PROTECTED] cc : Objet : RE: passing parameters or object from one action to other You can put them in the request as attributes and use a non-redirecting forward *but* then you are 'action chaining'. (Action chains are bad. n'kay) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, 5 June 2003 19:25 To: [EMAIL PROTECTED] Subject: passing parameters or object from one action to other hi all, I have an action1 whose forward is another action2. I need to pass some parameters or object from action1 to action2 I don't want to put them(parameters or object) in the session. Is there a solution for doing that. thanks in advance Meissa L'integrite de ce message n'etant pas assuree sur internet, Natexis Banques Populaires ne peut etre tenu responsable de son contenu. Toute utilisation ou diffusion non autorisee est interdite. Si vous n'etes pas destinataire de ce message, merci de le detruire et d'avertir l'expediteur. The integrity of this message cannot be guaranteed on the Internet. Natexis Banques Populaires can not therefore be considered responsible for the contents.Any unauthorized use or dissemination is prohibited. If you are not the intended recipient of this message, then please delete it and notify the sender. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] L'integrite de ce message n'etant pas assuree sur internet, Natexis Banques Populaires ne peut etre tenu responsable de son contenu. Toute utilisation ou diffusion non autorisee est interdite. Si vous n'etes pas destinataire de ce message, merci de le detruire et d'avertir l'expediteur. The integrity of this message cannot be guaranteed on the Internet. Natexis Banques Populaires can not therefore be considered responsible for the contents.Any unauthorized use or dissemination is prohibited. If you are not the intended recipient of this message, then please delete it and notify the sender.
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]
RE: Passing parameters with requestURI of display:table tag
See Struts html:rewrite tag. It should make your life easier. Something like this: bean:define id='pagingRequestURI' html:rewrite page='/myAction.do' paramName='myField'/ /bean:define display:table requestURI='%= pagingRequestURI %' ... However in the rewrite you'll need myField to be a scoped variable (bean). -Original Message- From: Susan Bradeen [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 09, 2003 3:11 PM To: [EMAIL PROTECTED] Subject: Passing parameters with requestURI of display:table tag And speaking of Ed Hill's Display tags (yes, very useful) ... I am having trouble figuring out how to pass parameters with the requestURI attribute of a display:table tag without breaking the paging functionality. I've got an Action path set to the requestURI, and the display:table tag automatically adds on the ?page=# parameter for each header page link. All is well. Now I am using the tags with an Action that requires an input parameter in order to rebuild the JSP. (As ugly as the following code is) I add my parameter to the requestURI, but then end up with two ? in the resolved url. I have in my JSP: snip display:table name=myform property=myList pagesize=15 requestURI='%=((String)request.getAttribute(modulePrefix)). concat(/myAction.do?field= + request.getParameter(myField) + ))%' decorator=com.myCompany.decorator.myDecorator /snip This resolves to http:/... /myAction.do?field=someValue?page=2 for the url of my list page 2. Within the display:column tag you can use the paramName and paramId properties, but they are not available for display:table. In scanning through the TableTag source code, it looks like there is a check for the presence of a ? in the url, which should cause the page parameter to get added on the end like page=2. However, this is not happening. Hopefully, I am missing something basic. Has anyone had experience with this? I hope my question is clear, I could really use some help! Thanks, Susan Bradeen SoftLanding Systems, Inc [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Passing parameters with requestURI of display:table tag
Correction: need the paramId attribute too: html:rewrite page='/myAction.do' paramId='myField' paramName='myFieldBean'/ -Original Message- From: Jerome Jacobsen [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 09, 2003 3:30 PM To: Struts Users Mailing List Subject: RE: Passing parameters with requestURI of display:table tag See Struts html:rewrite tag. It should make your life easier. Something like this: bean:define id='pagingRequestURI' html:rewrite page='/myAction.do' paramName='myField'/ /bean:define display:table requestURI='%= pagingRequestURI %' ... However in the rewrite you'll need myField to be a scoped variable (bean). -Original Message- From: Susan Bradeen [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 09, 2003 3:11 PM To: [EMAIL PROTECTED] Subject: Passing parameters with requestURI of display:table tag And speaking of Ed Hill's Display tags (yes, very useful) ... I am having trouble figuring out how to pass parameters with the requestURI attribute of a display:table tag without breaking the paging functionality. I've got an Action path set to the requestURI, and the display:table tag automatically adds on the ?page=# parameter for each header page link. All is well. Now I am using the tags with an Action that requires an input parameter in order to rebuild the JSP. (As ugly as the following code is) I add my parameter to the requestURI, but then end up with two ? in the resolved url. I have in my JSP: snip display:table name=myform property=myList pagesize=15 requestURI='%=((String)request.getAttribute(modulePrefix)). concat(/myAction.do?field= + request.getParameter(myField) + ))%' decorator=com.myCompany.decorator.myDecorator /snip This resolves to http:/... /myAction.do?field=someValue?page=2 for the url of my list page 2. Within the display:column tag you can use the paramName and paramId properties, but they are not available for display:table. In scanning through the TableTag source code, it looks like there is a check for the presence of a ? in the url, which should cause the page parameter to get added on the end like page=2. However, this is not happening. Hopefully, I am missing something basic. Has anyone had experience with this? I hope my question is clear, I could really use some help! Thanks, Susan Bradeen SoftLanding Systems, Inc [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Passing parameters with requestURI of display:table tag
Thanks, Jerome, I will definitely give this a try. Susan On 01/09/2003 03:34:44 PM Jerome Jacobsen wrote: Correction: need the paramId attribute too: html:rewrite page='/myAction.do' paramId='myField' paramName='myFieldBean'/ -Original Message- From: Jerome Jacobsen [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 09, 2003 3:30 PM To: Struts Users Mailing List Subject: RE: Passing parameters with requestURI of display:table tag See Struts html:rewrite tag. It should make your life easier. Something like this: bean:define id='pagingRequestURI' html:rewrite page='/myAction.do' paramName='myField'/ /bean:define display:table requestURI='%= pagingRequestURI %' ... However in the rewrite you'll need myField to be a scoped variable (bean). -Original Message- From: Susan Bradeen [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 09, 2003 3:11 PM To: [EMAIL PROTECTED] Subject: Passing parameters with requestURI of display:table tag And speaking of Ed Hill's Display tags (yes, very useful) ... I am having trouble figuring out how to pass parameters with the requestURI attribute of a display:table tag without breaking the paging functionality. I've got an Action path set to the requestURI, and the display:table tag automatically adds on the ?page=# parameter for each header page link. All is well. Now I am using the tags with an Action that requires an input parameter in order to rebuild the JSP. (As ugly as the following code is) I add my parameter to the requestURI, but then end up with two ? in the resolved url. I have in my JSP: snip display:table name=myform property=myList pagesize=15 requestURI='%=((String)request.getAttribute(modulePrefix)). concat(/myAction.do?field= + request.getParameter(myField) + ))%' decorator=com.myCompany.decorator.myDecorator /snip This resolves to http:/... /myAction.do?field=someValue?page=2 for the url of my list page 2. Within the display:column tag you can use the paramName and paramId properties, but they are not available for display:table. In scanning through the TableTag source code, it looks like there is a check for the presence of a ? in the url, which should cause the page parameter to get added on the end like page=2. However, this is not happening. Hopefully, I am missing something basic. Has anyone had experience with this? I hope my question is clear, I could really use some help! Thanks, Susan Bradeen SoftLanding Systems, Inc [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: passing parameters
Go to www.amazon.com. Search for books, Mastering Jakarta Struts. Click checkout. Purchase book. Read it, learn it, live it. Mark -Original Message- From: Craig Longman [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 11, 2002 6:58 AM To: struts-user Subject: passing parameters i'm very new to struts. i've been using systems that are more script oriented, but find that struts is a better fit for keeping things in the webpage simple, so i'm delving in to try and understand it. the first that threw me for a loop was the apparent total lack of support for hashtables, other than simply iterating through them. much of my thinking and code is going to have to change to accommodate that. if i've mis-read the documents that my searches produced and hashtables are in fact well supported, someone please correct me. the first problem i'm having, is figuring out how to call some of my code in an attempt to have it do the work hashtables used to do. for example, i have a system that produces a 'where am i' menu for the user, something like: home - search - results - detail this is done dynamically. what i need to have happen, is for each page to be able to invoke a method and pass in the name of the current page, the return value will then be an object representing the 'current page'. but how does one accomplish this? can one even accomplish it without writing custom tags? any help would be greatly appreciated. -- CraigL-Thx(); Be Developer ID: 5852 -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: passing parameters
On Wed, 2002-09-11 at 08:15, Galbreath, Mark wrote: Go to www.amazon.com. Search for books, Mastering Jakarta Struts. Click checkout. Purchase book. Read it, learn it, live it. thats great. thanks. -- CraigL-Thx(); Be Developer ID: 5852 signature.asc Description: This is a digitally signed message part
RE: Passing parameters directly to Action Servlet
You can use the query string to pass parameters to your Action class: http://www.whatever.com/myapp/myaction.do?color=red Then use request.getParameter(color) to retrieve the query parameter in the Action class. In this case you are still using an Action class not Action Servlet. Don't confuse ActionServlet with Action class. The .do request is sent to your subclass of Action by the ActionServlet object as defined in your struts-config.xml file. You could use an ActionForm as well. In the above example, it would have a setColor() method that would get called when the above URL as accessed. Tim -Original Message- From: ajTreece [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 01, 2002 1:57 PM To: Struts Users Mailing List Subject: Passing parameters directly to Action Servlet Is it possible... And how do you pass parameters directly to a action servlet without the use of a jsp and action form. What I'm doing is reading DB CLOB which is actually just XML data an spitting in out to an newly opened browser window. The originating JSP will just have a bunch of links that pass the id number and display type to the action servlet (.do). The .do will get the data, format it as required and give it to a jsp to display. Is this possible or am I barking up the wrong tree... Thanks, ajTreece -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Passing parameters directly to Action Servlet
Yes I just didn't realize it was that simple. Later, ajTreece James Mitchell wrote: If I'm not way off [again ;)] Are you wanting to do this? html:link page=/strutsaction.do?param1=value1param2=value2/ JM -Original Message- From: ajTreece [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 01, 2002 4:57 PM To: Struts Users Mailing List Subject: Passing parameters directly to Action Servlet Is it possible... And how do you pass parameters directly to a action servlet without the use of a jsp and action form. What I'm doing is reading DB CLOB which is actually just XML data an spitting in out to an newly opened browser window. The originating JSP will just have a bunch of links that pass the id number and display type to the action servlet (.do). The .do will get the data, format it as required and give it to a jsp to display. Is this possible or am I barking up the wrong tree... Thanks, ajTreece -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Passing parameters
use a flag variable in the form -Original Message- From: Bhaskar Gopalan [mailto:[EMAIL PROTECTED]] Sent: Friday, April 19, 2002 10:09 AM To: Struts Group (E-mail) Subject: Passing parameters Hi, I am going to a jsp(A) from two different jsps(B,C). Now, when I click 'save' on A I want to go back to B or C, .i.e. to where I came from. I send the source as a request parameter which is visible in action class of A. Now, when I am done, can i pass the source thru mapping.findForward()? Thnx, GB -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Passing parameters
you could do something like this in your action: String forwardPath = /action/Blah?source= + sourceValue; return new ActionForward(forwardPath, true); // which sets redirect=true OR return new ActionForward(forwardPath); // which is redirect=false Sincerely, Shane Witbeck __ Developer, Bank of America email: [EMAIL PROTECTED] phone: 904.987.1688 -Original Message- From: Bhaskar Gopalan [mailto:[EMAIL PROTECTED]] Sent: Friday, April 19, 2002 10:09 AM To: Struts Group (E-mail) Subject: Passing parameters Hi, I am going to a jsp(A) from two different jsps(B,C). Now, when I click 'save' on A I want to go back to B or C, .i.e. to where I came from. I send the source as a request parameter which is visible in action class of A. Now, when I am done, can i pass the source thru mapping.findForward()? Thnx, GB -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Passing parameters
You could also return a new ActionForward object passing the parameters you want. I don't think it works with mapping.findForward(). --- Leonardo Maciel [EMAIL PROTECTED] escreveu: use a flag variable in the form -Original Message- From: Bhaskar Gopalan [mailto:[EMAIL PROTECTED]] Sent: Friday, April 19, 2002 10:09 AM To: Struts Group (E-mail) Subject: Passing parameters Hi, I am going to a jsp(A) from two different jsps(B,C). Now, when I click 'save' on A I want to go back to B or C, .i.e. to where I came from. I send the source as a request parameter which is visible in action class of A. Now, when I am done, can i pass the source thru mapping.findForward()? Thnx, GB -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] = Frederico Ferro Schuh [EMAIL PROTECTED] ICQ: 20486081 ___ Yahoo! Empregos O trabalho dos seus sonhos pode estar aqui. Cadastre-se hoje mesmo no Yahoo! Empregos e tenha acesso a milhares de vagas abertas! http://br.empregos.yahoo.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: passing parameters
Alternatively, I believe that the Action class supports a parameter attribute, which you could possibly use if the Action class doesn't use it itself. -Original Message- From: Albertsen, Juergen [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 8:27 AM To: 'Struts Users Mailing List' Cc: Bridges, Edward Subject: AW: passing parameters You have to use a custom Mapping class. Depending on whether you use Struts 1.0 or the 1.1-dev prerelease you either specify the mapping class globally or for each action mapping. In case of the former - 1.0.x - you use an init parameter called mapping when configuring the Action servlet in the web.xml descriptor. In case of the latter - 1.1-dev - you would use the className attribute in the action element of the struts-config. (BTW, is there any elegant way to globally set the mapping class to be used? I could not find one). This mapping class should provide the properties in question and appropriate getter and setter methods (in your case needsLogin). In the perform() method of your Action class you can then cast the mapping parameter to your custom mapping class and retreive the value for the property. Regards, Jürgen -Ursprüngliche Nachricht- Von: Edward Q. Bridges [mailto:[EMAIL PROTECTED]] Gesendet: Donnerstag, 28. Februar 2002 15:25 An: Struts Users Mailing List Betreff: passing parameters simple question, (i hope!) if i set a property for an action in struts-config.xml like this: action path=/view-channels type=contentdb.view.channels.ViewChannelsAction name=viewChannelsForm scope=request validate=true input=/WEB-INF/jsp/ViewChannelItems.jsp set-property property=needsLogin value=true/ /action how could i then retrieve the value of needsLogin from an Action class? thanks! --e-- -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: passing parameters from a template to a sub-template
There is an error in your code : try to remove the ending '/' in file '/template/index.jsp' line template:put attribute=site direct=true/ -^-- error Also, you can have a look to Components/Extended Templates proposal : it provides more features to deal with templates / sub-templates. Cedric Components sites : http://www.lifl.fr/~dumoulin/components/ (mirror) : http://www.geocities.com/cedricdumoulin/components/ Matthew Kennedy wrote: Hello, I'm just starting out with struts and I have run into a problem. I have a file 'index.jsp' which is a template. It inserts '/template/index.jsp' and puts the parameter 'site'. In turn, '/template/index.jsp' gets parameter 'site' and makes a put for the 'site' parameter of template called '/template/top_categories.jsp' which '/template/index.jsp' inserts. Hope that doesn't sound to confusing? Basically, I have the following: index.jsp (puts site='documentation') | V /template/index.jsp (gets site then puts site) | V /template/top_categories.jsp (gets site) I am trying to achieve the middle part with the following fragment from '/template/index.jsp' (see below for the full code). template:insert template=/template/top_categories.jsp/ template:put name=site direct=true/ template:get name=site/ /template:put /template:insert Of course, this doesn't work (the exception encountered is below). So what technique do Struts users use to achieve this templates within templates implementation? Is it possible? Many thanks, Matthew /index.jsp %@ page contentType=text/html % %@ taglib uri=/WEB-INF/tlds/struts/struts-template.tld prefix=template % template:insert template=/template/index.jsp template:put name=site content=documentation direct=true/ /template:insert /template/index.jsp %@ taglib uri=/WEB-INF/tlds/struts/struts-template.tld prefix=template% !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html lang=en head titleSite - template:get name=site//title /head body template:insert template=/template/top_categories.jsp/ template:put name=site direct=true/ template:get name=site/ /template:put /template:insert /body /html /template/top_categories.jsp %@taglib uri=/WEB-INF/tlds/dbtags/dbtags.tld prefix=sql% %@taglib uri=/WEB-INF/tlds/struts/struts-template.tld prefix=template% sql:connection id=conn sql:urljdbc:postgresql://localhost/test/sql:url sql:driverorg.postgresql.Driver/sql:driver sql:userIdtest/sql:userId sql:password/ /sql:connection h1 class=top_categoriesCategories/h1 table sql:statement id=stmt conn=conn sql:query SELECT id, title FROM category WHERE parent_id IS NULL /sql:query sql:resultSet id=rset tr td a href=%= request.getContextPath() %/index.jsp?site=template:get name=site/category=sql:getColumn position=1/sql:getColumn position=2//a /td /td /sql:resultSet /sql:statement /table sql:closeConnection conn=conn/ 500 error Internal Servlet Error: javax.servlet.ServletException: PutTag.doEndTag(): No InsertTag ancestor at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459) at _0002findex_0002ejspindex_jsp_19._jspService(_0002findex_0002ejspindex_jsp_19.java:127) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:177) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404) at org.apache.tomcat.core.Handler.service(Handler.java:286) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743) at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498) at java.lang.Thread.run(Thread.java:484)