Struts 2 : redirect to action method on type conversion fail ?
Hi, I've got a form with s:textfield mapped with Long variables in my action class. Also, my jsp displays some pre-computed information (that I retrieve from database in my action's method). When the user types letters in the number field, the type conversion fails, and the JSP is reloaded. But the pre-computed infos are no more displayed (because we did not execute the action's method). I didn't find a way to redirect to the action's method even if type conversion fails. So I tried to store the pre-computed infos in http parameters by adding a hidden field : s:hidden name=archiveProfile.name / s:property value=archiveProfile.name/ it did not work because of the archiveProfile thing. I currently use a workaround, a s:hidden name=display/ field that forces struts 2 to execute the setter : public void setDisplay(String display){ display(); } (display() is my method which loads stuff from db.) That works but i'm afraid of potential side-effects, do you have a better idea ? Thanks, Thomas - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 : redirect to action method on type conversion fail ?
Use Preparable interface instead http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/Preparable.html Regards -- Łukasz http://www.lenart.org.pl/ Kapituła Javarsovia 2010 http://javarsovia.pl - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Struts release 2.1.9
Hi, When will there be a GA release of 2.1.9 or above? Cheers, Jake - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 : redirect to action method on type conversion fail ?
That interceptor looks great, but is there any way to access request parameters in the prepare() method ? The http request provides an archiveProfileId parameter and I use that parameter to load my object archiveProfile. 2010/5/10 Lukasz Lenart lukasz.len...@googlemail.com: Use Preparable interface instead http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/Preparable.html Regards -- Łukasz http://www.lenart.org.pl/ Kapituła Javarsovia 2010 http://javarsovia.pl - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts release 2.1.9
2010/5/10 j...@researchtogether.com: When will there be a GA release of 2.1.9 or above? Hope soon! We're planing to use Nexus to make a release and right now I'm waiting for access. Regards -- Łukasz http://www.lenart.org.pl/ Kapituła Javarsovia 2010 http://javarsovia.pl - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 : redirect to action method on type conversion fail ?
Hi Thomas, use the paramsPrepareParams interceptor stack (or change yours), from struts-default.xml: !-- An example of the paramsPrepareParams trick. This stack is exactly the same as the defaultStack, except that it includes one extra interceptor before the prepare interceptor: the params interceptor. This is useful for when you wish to apply parameters directly to an object that you wish to load externally (such as a DAO or database or service layer), but can't load that object until at least the ID parameter has been loaded. By loading the parameters twice, you can retrieve the object in the prepare() method, allowing the second params interceptor to apply the values on the object. -- interceptor-stack name=paramsPrepareParamsStack ... I think this accomplishes what you are looking for (of course you need setters for the parameters that you want params interceptor to have ready for you by the time the prepare() method is called). Em 10-05-2010 09:39, Thomas Lulé escreveu: That interceptor looks great, but is there any way to access request parameters in the prepare() method ? The http request provides an archiveProfileId parameter and I use that parameter to load my object archiveProfile. 2010/5/10 Lukasz Lenartlukasz.len...@googlemail.com: Use Preparable interface instead http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/Preparable.html Regards -- Łukasz http://www.lenart.org.pl/ Kapituła Javarsovia 2010 http://javarsovia.pl - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 : redirect to action method on type conversion fail ?
It works. Thanks a lot Lukasz and Alex. 2010/5/10 Alex Rodriguez Lopez alo...@flordeutopia.pt: Hi Thomas, use the paramsPrepareParams interceptor stack (or change yours), from struts-default.xml: !-- An example of the paramsPrepareParams trick. This stack is exactly the same as the defaultStack, except that it includes one extra interceptor before the prepare interceptor: the params interceptor. This is useful for when you wish to apply parameters directly to an object that you wish to load externally (such as a DAO or database or service layer), but can't load that object until at least the ID parameter has been loaded. By loading the parameters twice, you can retrieve the object in the prepare() method, allowing the second params interceptor to apply the values on the object. -- interceptor-stack name=paramsPrepareParamsStack ... I think this accomplishes what you are looking for (of course you need setters for the parameters that you want params interceptor to have ready for you by the time the prepare() method is called). Em 10-05-2010 09:39, Thomas Lulé escreveu: That interceptor looks great, but is there any way to access request parameters in the prepare() method ? The http request provides an archiveProfileId parameter and I use that parameter to load my object archiveProfile. 2010/5/10 Lukasz Lenartlukasz.len...@googlemail.com: Use Preparable interface instead http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/Preparable.html Regards -- Łukasz http://www.lenart.org.pl/ Kapituła Javarsovia 2010 http://javarsovia.pl - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 : redirect to action method on type conversion fail ?
One last thing : Even if everything works, I still get a stacktrace when I submit the form to save my object. I think that the params interceptor tries to set the properties of the object jspProfile I have in my form (with s:checkbox name=jspProfile.recpCheckErrorCount/ for example), before the prepare interceptor initialize that object. Even if I initialize the object in the action's constructor, I get the stack. 2010-05-10 12:34:12,062 [http-8080-Processor24] WARN com.opensymphony.xwork2.ognl.OgnlValueStack - Error setting value ognl.OgnlException: target is null for setProperty(null, recpCheckErrorCount, [Ljava.lang.String;@62812d) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1651) at ognl.ASTProperty.setValueBody(ASTProperty.java:101) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.ASTChain.setValueBody(ASTChain.java:172) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.Ognl.setValue(Ognl.java:476) at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:192) at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:155) at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:143) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:273) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:187) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) ... 2010/5/10 Thomas Lulé tho...@lule.fr: It works. Thanks a lot Lukasz and Alex. 2010/5/10 Alex Rodriguez Lopez alo...@flordeutopia.pt: Hi Thomas, use the paramsPrepareParams interceptor stack (or change yours), from struts-default.xml: !-- An example of the paramsPrepareParams trick. This stack is exactly the same as the defaultStack, except that it includes one extra interceptor before the prepare interceptor: the params interceptor. This is useful for when you wish to apply parameters directly to an object that you wish to load externally (such as a DAO or database or service layer), but can't load that object until at least the ID parameter has been loaded. By loading the parameters twice, you can retrieve the object in the prepare() method, allowing the second params interceptor to apply the values on the object. -- interceptor-stack name=paramsPrepareParamsStack ... I think this accomplishes what you are looking for (of course you need setters for the parameters that you want params interceptor to have ready for you by the time the prepare() method is called). Em 10-05-2010 09:39, Thomas Lulé escreveu: That interceptor looks great, but is there any way to access request parameters in the prepare() method ? The http request provides an archiveProfileId parameter and I use that parameter to load my object archiveProfile. 2010/5/10 Lukasz Lenartlukasz.len...@googlemail.com: Use Preparable interface instead http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/Preparable.html Regards -- Łukasz http://www.lenart.org.pl/ Kapituła Javarsovia 2010 http://javarsovia.pl - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 : redirect to action method on type conversion fail ?
Nevermind, my stacktrace came from that issue : https://issues.apache.org/jira/browse/WW-2850 2010/5/10 Thomas Lulé tho...@lule.fr: One last thing : Even if everything works, I still get a stacktrace when I submit the form to save my object. I think that the params interceptor tries to set the properties of the object jspProfile I have in my form (with s:checkbox name=jspProfile.recpCheckErrorCount/ for example), before the prepare interceptor initialize that object. Even if I initialize the object in the action's constructor, I get the stack. 2010-05-10 12:34:12,062 [http-8080-Processor24] WARN com.opensymphony.xwork2.ognl.OgnlValueStack - Error setting value ognl.OgnlException: target is null for setProperty(null, recpCheckErrorCount, [Ljava.lang.String;@62812d) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1651) at ognl.ASTProperty.setValueBody(ASTProperty.java:101) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.ASTChain.setValueBody(ASTChain.java:172) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.Ognl.setValue(Ognl.java:476) at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:192) at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:155) at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:143) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:273) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:187) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) ... 2010/5/10 Thomas Lulé tho...@lule.fr: It works. Thanks a lot Lukasz and Alex. 2010/5/10 Alex Rodriguez Lopez alo...@flordeutopia.pt: Hi Thomas, use the paramsPrepareParams interceptor stack (or change yours), from struts-default.xml: !-- An example of the paramsPrepareParams trick. This stack is exactly the same as the defaultStack, except that it includes one extra interceptor before the prepare interceptor: the params interceptor. This is useful for when you wish to apply parameters directly to an object that you wish to load externally (such as a DAO or database or service layer), but can't load that object until at least the ID parameter has been loaded. By loading the parameters twice, you can retrieve the object in the prepare() method, allowing the second params interceptor to apply the values on the object. -- interceptor-stack name=paramsPrepareParamsStack ... I think this accomplishes what you are looking for (of course you need setters for the parameters that you want params interceptor to have ready for you by the time the prepare() method is called). Em 10-05-2010 09:39, Thomas Lulé escreveu: That interceptor looks great, but is there any way to access request parameters in the prepare() method ? The http request provides an archiveProfileId parameter and I use that parameter to load my object archiveProfile. 2010/5/10 Lukasz Lenartlukasz.len...@googlemail.com: Use Preparable interface instead http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/Preparable.html Regards -- Łukasz http://www.lenart.org.pl/ Kapituła Javarsovia 2010 http://javarsovia.pl - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
how to set default focus field in s:form ?
Good afternoon, Struts1, I use html:form focus=field_name to focus a default field. For *struts2.1.8.1*, may I know the grammar of setting focus value for s:form please? s:form focus=field_name does not work. Thanks a lot! -- Lu Ying - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: how to set default focus field in s:form ?
Hi Lu, does this help http://struts.apache.org/2.1.8.1/docs/form.html ? Search for focusElement in this text. Best greetings, Paweł Wielgus. 2010/5/10 Emi Lu em...@encs.concordia.ca: Good afternoon, Struts1, I use html:form focus=field_name to focus a default field. For *struts2.1.8.1*, may I know the grammar of setting focus value for s:form please? s:form focus=field_name does not work. Thanks a lot! -- Lu Ying - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: how to set default focus field in s:form ?
I would like to know that aswell, so far I have been using javascript with jquery that is the lib that I use // somewhere inside the initial function $(input:text:visible:first).focus(); // or $(#othercontol).focus(); // if the first control is not a textbox. On Mon, May 10, 2010 at 15:52, Emi Lu em...@encs.concordia.ca wrote: Good afternoon, Struts1, I use html:form focus=field_name to focus a default field. For *struts2.1.8.1*, may I know the grammar of setting focus value for s:form please? s:form focus=field_name does not work. Thanks a lot! -- Lu Ying - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Ing. Luis Martín Canaval Sánchez Keep it small and simple.