RE: REPOST: Internationalized messages for pure JavaScript client side validations
Thanks Chris and Paul. We tried it ourselves, and it turned out that it is working fine. I guess the documentation (for both Struts 2 and WW) needs to be updated to remove this section. Thanks -Original Message- From: Paul Benedict [mailto:[EMAIL PROTECTED] Sent: Sunday, December 10, 2006 6:17 AM To: Struts Users Mailing List Subject: Re: REPOST: Internationalized messages for pure JavaScript client side validations Tarek, The Struts framework should be using the locale of the user. If you want to grab a certain language, have you set the locale first? Paul Chris Pratt wrote: Seems to me that if it returned a key instead of a message that you could use fmt:message key=${message}/ to retrieve the appropriate internationalized message cooresponding to the error. (*Chris*) On 12/4/06, Tarek Nabil [EMAIL PROTECTED] wrote: -Original Message- From: Tarek Nabil Sent: Wednesday, November 29, 2006 10:17 AM To: Struts Users Mailing List Subject: Internationalized messages for pure JavaScript client side validations Hi, I read the following in the documentation quote Errors are reported using the default validation message, not the internationalized version that the server-side might be aware of. This is a known issue. You may want to try the AJAX Client Side Validation for messages that are fully internationalized. /quote Is this feature impossible to implement using the current framework? I don't want to go to the server for simple client side validations and the internationalized messages are a must for me. I looked at the code and it seems that this expression is the one that yields the message ${validator.getMessage(action)?js_string} I'm not into freemarker but it seems to be calling something on the validator object. Is there a way we can enhance the validation object in some way so that it exposes the internationalized message or is this object not aware of the user's current locale at all? Could it be enhanced so that it is aware of it? Thanks, Tarek Nabil DISCLAIMER** ** This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** DISCLAIMER** ** This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any
REPOST: Internationalized messages for pure JavaScript client side validations
-Original Message- From: Tarek Nabil Sent: Wednesday, November 29, 2006 10:17 AM To: Struts Users Mailing List Subject: Internationalized messages for pure JavaScript client side validations Hi, I read the following in the documentation quote Errors are reported using the default validation message, not the internationalized version that the server-side might be aware of. This is a known issue. You may want to try the AJAX Client Side Validation for messages that are fully internationalized. /quote Is this feature impossible to implement using the current framework? I don't want to go to the server for simple client side validations and the internationalized messages are a must for me. I looked at the code and it seems that this expression is the one that yields the message ${validator.getMessage(action)?js_string} I'm not into freemarker but it seems to be calling something on the validator object. Is there a way we can enhance the validation object in some way so that it exposes the internationalized message or is this object not aware of the user's current locale at all? Could it be enhanced so that it is aware of it? Thanks, Tarek Nabil DISCLAIMER** ** This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Parameters not being set on Action in Struts 2
Thanks Ted. This is getting interesting. I was really surprised that it worked for you, I couldn't even wait til the weekend is over. On my extremely slow laptop at home, I went and downloaded Tomcat 5.5.20 and Struts 2.0.1, and tried it. Surprisingly, it DOES work! I've been trying this from the very first day inside JDeveloper. Just to eliminate the probability that it might be the embedded OC4J that has the problem, I installed the application on a standalone OC4J and I found that it exhibits the same behavior as the OC4J embedded inside JDeveloper. So, I guess that means one of two things: 1- This is a bug with OC4J (more likely) 2- The code uses some non-standard feature that is not supported by OC4J (very unlikely) Since Oracle AS 10g is our target platform, this could be a show stopper for us. It would simply mean that if this issue can not be resolved then we can not move to WW/Struts 2. I'm open to any suggestions on how to get to the bottom of this issue. From: Ted Husted [mailto:[EMAIL PROTECTED] Sent: Thu 11/30/2006 6:54 PM To: Struts Users Mailing List Subject: Re: Parameters not being set on Action in Struts 2 I dropped in the JARS from the the 2.0.1 showcase, and it seemd to work just fine. You might want to try deploying it on another workstation there. -Ted. On 11/29/06, Tarek Nabil [EMAIL PROTECTED] wrote: Thanks Ted. I sent the WAR file and zip file containing the source of the action to your email address directly. I have a couple of other questions that I'll post on another thread and I hope you'll help me with them, so that I can conclude my evaluation. DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. **
RE: Parameters not being set on Action in Struts 2
Looks like it is that issue indeed :( From: Ted Husted [mailto:[EMAIL PROTECTED] Sent: Fri 12/1/2006 4:34 PM To: Struts Users Mailing List Subject: Re: Parameters not being set on Action in Struts 2 On 12/1/06, Tarek Nabil [EMAIL PROTECTED] wrote: I'm open to any suggestions on how to get to the bottom of this issue. Maybe it's this * http://forums.opensymphony.com/thread.jspa?messageID=94747?? The sample was testing GET but not POST. -Ted. DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. **
RE: Does Struts 2 solve the action chaining problem?
Craig and Mark, Thanks a lot for pointing out the Preparable interface. I think that solves a major problem with Struts 1. I'm yet to experiment heavily with WW/Struts 2, but I feel like the Interceptor concept is a very powerful approach, though a bit dangerous if not well controlled. Craig, We, actually, decided that we don't want to get into JSF yet. But if this prerender method is equivalent to the onPageLoad() method in ASP .NET, then it's a very important piece that is really missing from the JSF spec. Yujun, Your idea is brilliant and it never crossed my mind. If we stick with Struts 1, I think I will try that. Christopher, I really wonder if the Struts you're talking about is the one I've using for years now!! The Struts I know sucks big time when it comes to action chaining. I'm afraid I don't understand how defining two mappings, one with validation turned on and the other turned off, solves the first problem! As for the second problem, your solution still involves action chaining which should be avoided unless you've done something equivalent to what Yujun did. Thanks everyone for your help. -Original Message- From: Christopher Schultz [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 5:36 PM To: Struts Users Mailing List Subject: Re: Does Struts 2 solve the action chaining problem? -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tarek, Tarek Nabil wrote: One of the problems with Struts was that if you had a page that requires some setup and this page submits to an Action, then you would not be able to set validate to true on that action because if validation problems occur then Struts will take you directly to the input JSP without performing the setup and your JSP wouldn't work. A solution to that would be to specify the input of the action as the setup action, which means you're doing action chaining and Struts is not good at that (it will reset your form among other things). The solution of choice for us so far was to call validate() ourselves in the action and if a validation problem occurs then we call the setup method (eventually you start using your action methods as an API which still was not good). I totally disagree. If you have an action that you want to use like this, you can always set up two different mappings -- one that /does/ validate and another that does /not/ validate. My experience has been that Struts is very good at action chaining... in fact, that's the major advantage of Struts in the first place: the ability to map URIs to actions and specify their relationships through forward mappings. Another problematic scenario is the case when you're editing some database record for example. When you go to your setup action for the first time, you will populate drop down lists for example, and then load the existing values from the database to your JSP fields. If the user attempts to save and some problem occurs then in the setup action, you will need to again populate the drop down lists, but you will NOT want to overwrite the user's inputs with the existing data. This is very similar to the first problem, but you would also need to pass some flag to the setup method to tell it whether to copy the data from the database to your ActionForm. In this case, what you want is something like: LoadAction - EditAction - Display form Form submits to SaveAction, which has EditAction as input (not LoadAction). This is pretty standard stuff, and works beautifully. Does Struts 2 or even WW 2.2.4 solve that problem in an elegant way? I really hope so, since Struts 1.x also does. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFbYyx9CaO5/Lv0PARArpHAJ0U3fHybMWepSZxPjciDU3+6M2PwQCgoy8B FRlfdQsyONpgqGvrHBuZuFw= =EbD/ -END PGP SIGNATURE- DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL
RE: Parameters not being set on Action in Struts 2
Thanks Ted. I sent the WAR file and zip file containing the source of the action to your email address directly. I have a couple of other questions that I'll post on another thread and I hope you'll help me with them, so that I can conclude my evaluation. -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 28, 2006 4:58 PM To: Struts Users Mailing List Subject: Re: Parameters not being set on Action in Struts 2 I inspected it myself in a debugger the other day, and the property was in the map. If you like, send me a WAR of the test application, so we can work out what's wrong. (The list doesn't accept attachments.) -Ted. On 11/28/06, Tarek Nabil [EMAIL PROTECTED] wrote: It exhibits the same behavior even after converting the param field/parameter to a String. Is there a way to provide a JUnit test for that? -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED] Sent: Monday, November 27, 2006 6:52 PM To: Struts Users Mailing List Subject: Re: Parameters not being set on Action in Struts 2 Try it again using a String property, to be sure it is not a problem with the type conversion. On 11/27/06, Tarek Nabil [EMAIL PROTECTED] wrote: To clear my doubts, I re-built this application using WW 2.2.4. I expected that it will work perfectly and that would prove it's some sort of a bug. To my surprise, it exhibited the exact same behavior! Now, since it's quite remote that such a drastic bug exists in WW 2.2.4, I'm starting to think that maybe the behavior I expect is not the correct one. Now, could someone please clarify whether the following is true? 1- When parameters are available in the query string, those parameters are made available to the action through ActionContext.getContext().getParameters(). Is this true? 2- If a property on the action has the same name as one of those parameters then the framework will attempt to set the property with the parameter's name. This is not what is currently happening. Since WW 2.2.4 is supposed to be production quality then I'm guessing that there must be something wrong with the configuration. It can not be that some configuration I've provided is wrong, simply because I have not provided any. It could be, though, that some configuration is missing. The changes I've made to the application to get it to work with WW 2.2.4 is minimal, so I won't go ahead and copy all the files here. DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Does Struts 2 solve the action chaining problem?
Hi, One of the problems with Struts was that if you had a page that requires some setup and this page submits to an Action, then you would not be able to set validate to true on that action because if validation problems occur then Struts will take you directly to the input JSP without performing the setup and your JSP wouldn't work. A solution to that would be to specify the input of the action as the setup action, which means you're doing action chaining and Struts is not good at that (it will reset your form among other things). The solution of choice for us so far was to call validate() ourselves in the action and if a validation problem occurs then we call the setup method (eventually you start using your action methods as an API which still was not good). Another problematic scenario is the case when you're editing some database record for example. When you go to your setup action for the first time, you will populate drop down lists for example, and then load the existing values from the database to your JSP fields. If the user attempts to save and some problem occurs then in the setup action, you will need to again populate the drop down lists, but you will NOT want to overwrite the user's inputs with the existing data. This is very similar to the first problem, but you would also need to pass some flag to the setup method to tell it whether to copy the data from the database to your ActionForm. Does Struts 2 or even WW 2.2.4 solve that problem in an elegant way? I remember coming across something about using Interceptors for that, but that would mean creating an Interceptor for almost every action of that type. I also noticed that there are some warnings in the documentation against using action chaining in Struts 2 as well. Thanks, Tarek Nabil DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Internationalized messages for pure JavaScript client side validations
Hi, I read the following in the documentation quote Errors are reported using the default validation message, not the internationalized version that the server-side might be aware of. This is a known issue. You may want to try the AJAX Client Side Validation for messages that are fully internationalized. /quote Is this feature impossible to implement using the current framework? I don't want to go to the server for simple client side validations and the internationalized messages are a must for me. I looked at the code and it seems that this expression is the one that yields the message ${validator.getMessage(action)?js_string} I'm not into freemarker but it seems to be calling something on the validator object. Is there a way we can enhance the validation object in some way so that it exposes the internationalized message or is this object not aware of the user's current locale at all? Could it be enhanced so that it is aware of it? Thanks, Tarek Nabil DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Parameters not being set on Action in Struts 2
Thanks Peter and Ted. I'm afraid I didn't understand your advice regarding the IDE with integrated debugging. Would that require me to use the source of Struts 2 rather than the JAR files as part of my application? To keep things simple, I started an application from scratch. Kept things to the bare minimum and I can still confirm that the problem exists. web.xml === ?xml version=1.0 encoding=UTF-8? web-app id=WebApp_9 version=2.4 xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; display-nameStruts Blank/display-name filter filter-namestruts2/filter-name filter-classorg.apache.struts2.dispatcher.FilterDispatcher/filter-cla ss /filter filter-mapping filter-namestruts2/filter-name url-pattern/*/url-pattern /filter-mapping listener listener-classorg.springframework.web.context.ContextLoaderListener/l istener-class /listener /web-app Struts.xml == !DOCTYPE struts PUBLIC -//Apache Software Foundation//DTD Struts Configuration 2.0//EN http://struts.apache.org/dtds/struts-2.0.dtd; struts package name=sample extends=struts-default action name=sample class=sample.SampleAction result/Sample.jsp/result /action /package /struts SampleAction.java = package sample; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; public class SampleAction extends ActionSupport { private Integer param; public String execute() { System.out.println(ActionContext.getContext().getParameters() = + ActionContext.getContext().getParameters()); return SUCCESS; } public void setParam(Integer param) { this.param = param; } public Integer getParam() { return param; } } Sample.jsp == %@ page contentType=text/html;charset=UTF-8% %@ taglib prefix=s uri=/struts-tags % html head titleSample/title /head body h2param = s:property value=param//h2 /body /html applicationContext.xml == ?xml version=1.0 encoding=UTF-8? !DOCTYPE beans PUBLIC -//SPRING//DTD BEAN//EN http://www.springframework.org/dtd/spring-beans.dtd; beans default-autowire=autodetect !-- add your spring beans here -- /beans struts.properties = EMPTY Configured the context path to be sample. Ran the application and put this URL in the address bar http://cpu2800:8988/sample/sample.action?param=1 That produced the following in the console (as I did away with logging, just plain System.out.println) 06/11/27 17:23:33 ActionContext.getContext().getParameters() = {} And my browser showed the following param = I can assure you that those are the only files in my project. Thanks again for your help. -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED] Sent: Sunday, November 26, 2006 6:07 PM To: Struts Users Mailing List Subject: Re: Parameters not being set on Action in Struts 2 On 11/26/06, Tarek Nabil [EMAIL PROTECTED] wrote: I was pretty sure that the correct method was being executed, because I had some logging statements inside. One of those statements is the one that attempts to log the parameter Map and it's still giving the same result; an empty Map. We'd need to see all the code exactly as it's written. For example, logger.debug(getContext().getParameters()); won't work, unless the Action has added a getContext method of its own. To simplify the test, try instead logger.debug(ActionContext.getContext().getParameters()); I added tried calling ActionContext.getContext in one of my own Actions and set a breakpoint in IDEA, to be sure it works correctly. One thing to not about type property is that it is an integer, so be sure your test is passing an integer as a parameter. That should affect the map, but it would affect what's set to the property. If time is going to be an issue, I'd strongly recommend trying an IDE with integrating debugging, since a quick step through can save a lot of temporary logging statements. The W2/S2 framework is also very testable, and nothing saves more development time than a solid set of unit tests from the get-go. If your application does need to do alot of logging, a very good place to do that is from an Intercetpor, so that the logging can be applied uniformly. HTH, Ted. DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received
RE: Parameters not being set on Action in Struts 2
To clear my doubts, I re-built this application using WW 2.2.4. I expected that it will work perfectly and that would prove it's some sort of a bug. To my surprise, it exhibited the exact same behavior! Now, since it's quite remote that such a drastic bug exists in WW 2.2.4, I'm starting to think that maybe the behavior I expect is not the correct one. Now, could someone please clarify whether the following is true? 1- When parameters are available in the query string, those parameters are made available to the action through ActionContext.getContext().getParameters(). Is this true? 2- If a property on the action has the same name as one of those parameters then the framework will attempt to set the property with the parameter's name. This is not what is currently happening. Since WW 2.2.4 is supposed to be production quality then I'm guessing that there must be something wrong with the configuration. It can not be that some configuration I've provided is wrong, simply because I have not provided any. It could be, though, that some configuration is missing. The changes I've made to the application to get it to work with WW 2.2.4 is minimal, so I won't go ahead and copy all the files here. -Original Message- From: Tarek Nabil Sent: Monday, November 27, 2006 5:29 PM To: Struts Users Mailing List Subject: RE: Parameters not being set on Action in Struts 2 Thanks Peter and Ted. I'm afraid I didn't understand your advice regarding the IDE with integrated debugging. Would that require me to use the source of Struts 2 rather than the JAR files as part of my application? To keep things simple, I started an application from scratch. Kept things to the bare minimum and I can still confirm that the problem exists. web.xml === ?xml version=1.0 encoding=UTF-8? web-app id=WebApp_9 version=2.4 xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; display-nameStruts Blank/display-name filter filter-namestruts2/filter-name filter-classorg.apache.struts2.dispatcher.FilterDispatcher/filter-cla ss /filter filter-mapping filter-namestruts2/filter-name url-pattern/*/url-pattern /filter-mapping listener listener-classorg.springframework.web.context.ContextLoaderListener/l istener-class /listener /web-app Struts.xml == !DOCTYPE struts PUBLIC -//Apache Software Foundation//DTD Struts Configuration 2.0//EN http://struts.apache.org/dtds/struts-2.0.dtd; struts package name=sample extends=struts-default action name=sample class=sample.SampleAction result/Sample.jsp/result /action /package /struts SampleAction.java = package sample; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; public class SampleAction extends ActionSupport { private Integer param; public String execute() { System.out.println(ActionContext.getContext().getParameters() = + ActionContext.getContext().getParameters()); return SUCCESS; } public void setParam(Integer param) { this.param = param; } public Integer getParam() { return param; } } Sample.jsp == %@ page contentType=text/html;charset=UTF-8% %@ taglib prefix=s uri=/struts-tags % html head titleSample/title /head body h2param = s:property value=param//h2 /body /html applicationContext.xml == ?xml version=1.0 encoding=UTF-8? !DOCTYPE beans PUBLIC -//SPRING//DTD BEAN//EN http://www.springframework.org/dtd/spring-beans.dtd; beans default-autowire=autodetect !-- add your spring beans here -- /beans struts.properties = EMPTY Configured the context path to be sample. Ran the application and put this URL in the address bar http://cpu2800:8988/sample/sample.action?param=1 That produced the following in the console (as I did away with logging, just plain System.out.println) 06/11/27 17:23:33 ActionContext.getContext().getParameters() = {} And my browser showed the following param = I can assure you that those are the only files in my project. Thanks again for your help. -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED] Sent: Sunday, November 26, 2006 6:07 PM To: Struts Users Mailing List Subject: Re: Parameters not being set on Action in Struts 2 On 11/26/06, Tarek Nabil [EMAIL PROTECTED] wrote: I was pretty sure that the correct method was being executed, because I had some logging statements inside. One of those statements is the one that attempts to log the parameter Map and it's still giving the same result; an empty Map. We'd need to see all the code exactly as it's written. For example, logger.debug(getContext().getParameters
RE: Parameters not being set on Action in Struts 2
It exhibits the same behavior even after converting the param field/parameter to a String. Is there a way to provide a JUnit test for that? -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED] Sent: Monday, November 27, 2006 6:52 PM To: Struts Users Mailing List Subject: Re: Parameters not being set on Action in Struts 2 Try it again using a String property, to be sure it is not a problem with the type conversion. On 11/27/06, Tarek Nabil [EMAIL PROTECTED] wrote: To clear my doubts, I re-built this application using WW 2.2.4. I expected that it will work perfectly and that would prove it's some sort of a bug. To my surprise, it exhibited the exact same behavior! Now, since it's quite remote that such a drastic bug exists in WW 2.2.4, I'm starting to think that maybe the behavior I expect is not the correct one. Now, could someone please clarify whether the following is true? 1- When parameters are available in the query string, those parameters are made available to the action through ActionContext.getContext().getParameters(). Is this true? 2- If a property on the action has the same name as one of those parameters then the framework will attempt to set the property with the parameter's name. This is not what is currently happening. Since WW 2.2.4 is supposed to be production quality then I'm guessing that there must be something wrong with the configuration. It can not be that some configuration I've provided is wrong, simply because I have not provided any. It could be, though, that some configuration is missing. The changes I've made to the application to get it to work with WW 2.2.4 is minimal, so I won't go ahead and copy all the files here. DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Parameters not being set on Action in Struts 2
Thanks Ted. I renamed my method to execute and changed the URL to remove the !setup part. I also changed the struts.xml file accordingly, so now it's like that (note that I removed the input result, just in case it's causing any problems). action name=dod1 class=packagename.ActionClassName result name=page/jsp/billCreation/PageName.jsp/result /action I was pretty sure that the correct method was being executed, because I had some logging statements inside. One of those statements is the one that attempts to log the parameter Map and it's still giving the same result; an empty Map. I know you guys are doing a great effort trying to get this framework out, but if I have a project starting in one month and delivering four months later, would you recommend Struts 2 for that? Please note that means that most development will be done using a pre-release version, so do you think this version is stable enough to be used by a team of 30 to 40 people where delays could cause a great damage? And, although I know this question is very difficult to answer for OS projects, do you think this framework will be ready for prime time in 5 months? The application is a heavy transactional one and is required to scale for thousands of transactions per day. Your advice is greatly appreciated. -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED] Sent: Saturday, November 25, 2006 5:25 PM To: Struts Users Mailing List Subject: Re: Parameters not being set on Action in Struts 2 First, simplify the problem. Right now, the code seems to be calling an alternative method, setup. What happens if you try the same thing with the default execute method? If your application is based on the blank application, it may turned the ! syntax off, since it can conflict with using wildcards. To use the Check the struts.properties file for the line struts.enable.DynamicMethodInvocation, and set it to true. We're working on some new code for Struts 2 that will extend the ! syntax so that it can happily coexist with wildcards. -Ted. On 11/23/06, Tarek Nabil [EMAIL PROTECTED] wrote: Hi, I'm experimenting with Struts 2, and I'm facing a problem with request parameters being populated on the Action. I checked out the source to make sure that the behavior I expect is the correct one, and judging by the source, it is, but it's not happening. I have an action that has a method public void setType(Integer type) { // some code } I declared the action in Struts.xml as follows action name=dod1 method=setup class=somePackageName.someClassName result name=page/jsp/someFolder/someJSP.jsp/result result name=input type=chaindod1!setup/result /action In the setup method, I put the following line logger.debug(getContext().getParameters()); In the URL, I call the following http://server/application/namespace/dod1!setup.action?type=1 The result is that the parameters map is logged as {} and in my method when I attempt to access the type field, I find it to be null! Could someone please point me to what could be wrong? Thanks, Tarek Nabil DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Parameters not being set on Action in Struts 2
Hi, I'm experimenting with Struts 2, and I'm facing a problem with request parameters being populated on the Action. I checked out the source to make sure that the behavior I expect is the correct one, and judging by the source, it is, but it's not happening. I have an action that has a method public void setType(Integer type) { // some code } I declared the action in Struts.xml as follows action name=dod1 method=setup class=somePackageName.someClassName result name=page/jsp/someFolder/someJSP.jsp/result result name=input type=chaindod1!setup/result /action In the setup method, I put the following line logger.debug(getContext().getParameters()); In the URL, I call the following http://server/application/namespace/dod1!setup.action?type=1 The result is that the parameters map is logged as {} and in my method when I attempt to access the type field, I find it to be null! Could someone please point me to what could be wrong? Thanks, Tarek Nabil DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Extending Themes
Hi, I'm currently evaluating Struts 2 for our next project. Our UI people have laid out some standards for the markup generated by the application pages, which the XHTML theme does not satisfy. I started looking into the Extending Themes topic, but it seems that there's no clear reference on how to do that. Following the examples does not seem to be very easy as I have not found any reference to explain some of the key words used in the templates, such as fieldErrors or parameters. For example, there's no reference that explains all the attributes exposed by parameters. Could some one please point me to such a reference if one exists? Thanks, Tarek Nabil DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Is Action Chaining Strongly Discouraged?
Dave, I'm not sure if you really read my message thoroughly. When I meant population, I meant for things like drop down lists, not for edit pages that come pre-populated with existing data to edit. If you always go back to the same page, then populating the drop down list has to be done whether you're going to the page directly or after an add/update, so that's why I was asking about redirecting, I thought you were doing the update then redirecting to the action that does the setup. As for the two approaches I've been asking for comments on...they're not the one below, bu the ones at the end of my email: 1- Put the setup information in the ActionForm class itself (not very inclined to go for that one). 2- Using a MappingDispatchAction without action chaining. Put the setup code in common methods in the action class. Configure two mappings for the same action class that will call two different methods, e.g. prepare and add. In both methods, I would call the common setup method before going back to the page, so it's minimal duplicated code (although duplication is not completely eliminated), but at least it's less awkward than retieving the form from the request scope by hand. Of course in number 2 above, I don't mean that the actual database call is in the action, but the call to the service method. Thanks -Original Message- From: Dave Newton [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 03, 2006 10:17 PM To: Struts Users Mailing List Subject: Re: Is Action Chaining Strongly Discouraged? Tarek Nabil wrote: Do you mean that you're doing a redirect after processing the post? Who, me? If no, ignore the following. I'm not sure I understand the question. In a nutshell: for a GET I do whatever population/misc. stuff I need to do then return the input forward. For a POST I validate and return the input forward if there are errors, otherwise I return whatever forward is warranted. In practice by classes have become more cumbersome than that with methods designed to be overridden that do pre- and post-processing etc. I've been thinking about this action chaining issue for some time since I used it in my last project and it resulted in some code duplication. Isn't that bass-ackwards? Even though I really dislike chaining shouldn't it have less code? 1- A prepare action when the page is called directly (a form bean is configured for that one). 2- A page action when it's called from another action (no form bean is configured to prevent resetting). *shudder* If no other reason here's a strong reason to move that logic out of the actions and into service objects; at least then you're just making calls rather than duplicating the code. Unless I completely misunderstood you. Would anyone care to comment on those two approaches? Does anyone have a different approach that I can consider? At first glance with no clue what you're trying to accomplish it sounds overly complicated. Dave DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: validation breaks my form prepopulation
If you don't associate your setup action with a form bean, the reset method will not be called, and whatever was in the form will be retained. -Original Message- From: Kyle W. Cartmell [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 03, 2006 2:39 AM To: Struts Users Mailing List Subject: Re: validation breaks my form prepopulation This is extremely helpful, because it gives me the opportunity to prepopulate my form once again should validation fail. There's still a sticky bit here, in that request attributes that are set from a previous form are lost and cannot be recreated. I believe that this is pretty much something that I have to just handle and there aren't any magic spells to drive that process, but please correct me if I'm wrong. :) Thanks again! Michael Jouravlev wrote: On 5/2/06, Kyle W. Cartmell [EMAIL PROTECTED] wrote: Within my web application (using the Struts action framework) when validation of an ActionForm fails and control is returned to the JSP indicated by struts-config.xml, any request attributes that were passed to that JSP originally are lost because a new request object has been created. input attribute of action element in struts-config.xml does not have to refer to JSP page directly, it can point to setup action of your JSP page. Michael. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Kyle W. Cartmell Sr. Software Developer LAP Holdings, LLC dba First Finance Phone: (480) 222-0050 Toll Free: (800) 355-3135 [EMAIL PROTECTED] www.efirstfinance.com DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: FW: mapping.getInput()
Actually, I wasn't indicating it should be any different, I just meant that it's an easier and more straightforward way of doing it. From: Pat Slater [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 02, 2006 7:35 PM To: Struts Users Mailing List; Tarek Nabil Subject: Re: FW: mapping.getInput() Used return mapping.getInputForward(); with no change in the result. Tarek Nabil [EMAIL PROTECTED] wrote: Not that it has anything to do with your problem, but why are you doing it this way? Why don't you do return mapping.getInputForward(); -Original Message- From: Pat Slater [mailto:[EMAIL PROTECTED] Sent: Sunday, April 30, 2006 7:22 PM To: user@struts.apache.org Subject: mapping.getInput() When returning back to the input html form page on Exception, mapping.getInput() returns correctly to that page but the form-fields entered by the user are not there anymore. This is a part of my code: public ActionForward saveMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { //.. try { myWork = saveMyWork(); //This throws a DateFieldException } catch(DateFieldException e) { ActionMessages errors = new ActionMessages(); ActionMessage error = new ActionMessage( errors.detail,e.getMessage() ); errors.add( ActionMessages.GLOBAL_MESSAGE,error ); saveErrors( request,errors ); return new ActionForward( mapping.getInput() ); //return mapping.findForward( failureDate ); } // } Has anybody experienced this? - Yahoo! Mail goes everywhere you do. Get it on your phone. DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Yahoo! Messenger with Voice. Make PC-to-Phone Calls http://us.rd.yahoo.com/mail_us/taglines/postman1/*http://us.rd.yahoo.com/evt=39663/*http://voice.yahoo.com to the US (and 30+ countries) for 2ยข/min or less. DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. **
RE: Is Action Chaining Strongly Discouraged?
Dave, Do you mean that you're doing a redirect after processing the post? I've been thinking about this action chaining issue for some time since I used it in my last project and it resulted in some code duplication. The reason is, I was storing the setup data in my form (which I still think is better than using multiple objects stored in request scope under multiple keys). When doing the chaining, I didn't want my form to get reset and lose all the request data when going to the second action, so I had to configure two action mappings for the same action: 1- A prepare action when the page is called directly (a form bean is configured for that one). 2- A page action when it's called from another action (no form bean is configured to prevent resetting). In the execute method, I was checking whether the form is null, and if it is, I would retrieve it from the request scope. I felt later that this was an awkward approach. Now, I have two more solutions that I'm considering. 1- Put the setup information in the ActionForm class itself (not very inclined to go for that one). 2- Using a MappingDispatchAction without action chaining. Put the setup code in common methods in the action class. Configure two mappings for the same action class that will call two different methods, e.g. prepare and add. In both methods, I would call the common setup method before going back to the page, so it's minimal duplicated code (although duplication is not completely eliminated), but at least it's less awkward than retieving the form from the request scope by hand. Would anyone care to comment on those two approaches? Does anyone have a different approach that I can consider? Thanks -Original Message- From: Dave Newton [mailto:[EMAIL PROTECTED] Sent: Monday, May 01, 2006 6:03 PM To: Struts Users Mailing List Subject: Re: Is Action Chaining Strongly Discouraged? David Evans wrote: Is there a reason you don't use the two action (setup and submit) approach? I just think it's cluttery. I always use POST so it's easy to just split my actions into GET and POST handlers; I do the setup in the GET handler. Dave DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
FW: mapping.getInput()
Not that it has anything to do with your problem, but why are you doing it this way? Why don't you do return mapping.getInputForward(); -Original Message- From: Pat Slater [mailto:[EMAIL PROTECTED] Sent: Sunday, April 30, 2006 7:22 PM To: user@struts.apache.org Subject: mapping.getInput() When returning back to the input html form page on Exception, mapping.getInput() returns correctly to that page but the form-fields entered by the user are not there anymore. This is a part of my code: public ActionForward saveMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { //.. try { myWork = saveMyWork(); //This throws a DateFieldException } catch(DateFieldException e) { ActionMessages errors = new ActionMessages(); ActionMessage error = new ActionMessage( errors.detail,e.getMessage() ); errors.add( ActionMessages.GLOBAL_MESSAGE,error ); saveErrors( request,errors ); return new ActionForward( mapping.getInput() ); //return mapping.findForward( failureDate ); } // } Has anybody experienced this? - Yahoo! Mail goes everywhere you do. Get it on your phone. DISCLAIMER This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us of the receipt thereof. If you have received this message in error, please notify the sender immediately, and delete this email from your system. Please note that e-mails are susceptible to change.The sender shall not be liable for the improper or incomplete transmission of the information contained in this communication,nor for any delay in its receipt or damage to your system.The sender does not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validation Configuration for Multiple Modules
Thanks Adam. I'm sure no one will be able to verify whether this was a bug in 1.1b2 (why I'm using b2 is a looong story, but I'm stuck with it). Is there a way I can find out from Bugzilla whether this was a bug that was fixed in later versions? - Original Message - From Adam Hardy [EMAIL PROTECTED] Date Wed, 12 Oct 2005 21:02:00 +0100 To Struts Users Mailing List user@struts.apache.org Subject Re: Validation Configuration for Multiple Modules [EMAIL PROTECTED] on 11/10/05 07:20, wrote: I'm using *Struts 1.1* to build an application with multiple Struts modules. I put my validations for each module in a seperate validations.xml file. For example, I have validations-a.xml for module a and validations-b.xml for module b. I then found out that although the validations are working perfectly for module a, they're not working at all for module b. I kept tracing the problem even in the Struts source code, and reached the conclusion that the validations for one module overwrite the other. It seems that the FormSet objects are stored in a HashMap with the locale as the key, and since both formsets have the same locale, one of them overwrites the other. Are my conclusions correct or am I doing something wrong? Does that mean I have to put all my validations for the whole application in one file? Presumably in each module's struts-config, your validator plugin node refers to the correct validation.xml? I doubt it's a bug since I successfully set up modularised struts with seperate validation.xml for each. Adam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Validation Configuration for Multiple Modules
Hi everyone, I'm using *Struts 1.1* to build an application with multiple Struts modules. I put my validations for each module in a seperate validations.xml file. For example, I have validations-a.xml for module a and validations-b.xml for module b. I then found out that although the validations are working perfectly for module a, they're not working at all for module b. I kept tracing the problem even in the Struts source code, and reached the conclusion that the validations for one module overwrite the other. It seems that the FormSet objects are stored in a HashMap with the locale as the key, and since both formsets have the same locale, one of them overwrites the other. Are my conclusions correct or am I doing something wrong? Does that mean I have to put all my validations for the whole application in one file? Please advise. Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]