Generics and custom Type Converter (Struts 2.1.8)
Hi I had a weird problem earlier where, if my pojo had a variable of type Date, struts was looking for setVariable(String) instead of a setVariable(Date) for browser locale = es_Cl. I wrote a custom type handler to solve this problem. Now am stuck with the same problem where I have a listObject into which Struts needs to set the date. From the documentation, I added the Element_variable, KeyProperty_variable and CreatIfNUll_variable, variable=Custom Type Handler into my property file. This is what happens 1. ) Struts by defaults looks for convertToString method in my converter class. 2.) When i set my debug, the setVariable is first called and then is the converter invoked. To solve problem1, I added convertValue and made it madatorily convert it to date and return that instead of a string. Even after that, Struts seems to be setting into an instance that isn't what is in the action class. As usual, this behaviour is just happening for es_CL locale on my browser and not when the browser locale is en_US. Any help is much appreciated. -- Regards Sundar S.
Locale based Type handler
Hi I use Struts 2.0.11 for my web application. I have a text field that maps to a java.util.date in my pojo. When my Locale is English, the date seems to be set fine, But when my locale is es_CL, struts seems to be searching for a setDate(java.lang.String) instead. Am not sure why this is happening and if I need to configure something, so that Struts would take care of setting the date object properly. Any help here is appreciated. Thanks, -- Regards Sundar S.
Re: FW: Type conversion for Date in es_CL Locale
More info on this! Looks like just for locale es_CL. OGNL is trying to find setXXX(String) and for locale en_US and es etc, it does figure out the setXXX(Date) Not sure why this is happening. Should i create a jira for this? Is there a work around that I may use.. Any info on this is appreciated Am having the latest set of jars of struts, ognl, and xwork. Regards Sundar 15:27:11,700 INFO [STDOUT] 2010-03-10 15:27:11,700 [OgnlValueStack:109] WARN - Error setting expression 'programVersionExclusion.effectiveDate' with value '[Ljava.lang.String;@1e0405' ognl.MethodFailedException: Method setEffectiveDate failed for object model.programversionexclus...@4e1a023 [java.lang.NoSuchMethodException: ...model.ProgramVersionExclusion.setEffectiveDate([Ljava.lang.String;)] at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1265) at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454) at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85) at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162) at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:28) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2225) at ognl.ASTProperty.setValueBody(ASTProperty.java:127) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220) at ognl.SimpleNode.setValue(SimpleNode.java:301) at ognl.ASTChain.setValueBody(ASTChain.java:227) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220) at ognl.SimpleNode.setValue(SimpleNode.java:301) at ognl.Ognl.setValue(Ognl.java:737) at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:198) at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:161) at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:149) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:276) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:187) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at