You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shrinivas Parashar <Sh...@symantec.com> on 2011/08/18 08:48:39 UTC

Struts 2.2.3 Date type convesrion issue

Hi,
I am getting following error if my model has a field of type java.util.Date. I am using struts 2.2.3. I have appropriate getter and setter method for birthday.
JSP snippet:
    	  <s:textfield name="user.birthday" label="Enter your birthday. (mm/dd/yy)"/>  	

java.lang.NoSuchMethodException: setBirthday([Ljava.lang.String;)
	at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1226)
	at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1474)
	at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
	at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
	at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:27)
	at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2245)
	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)

Regards,
Shrinivas

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2.2.3 Date type convesrion issue

Posted by Mano Pájaro <ma...@gmail.com>.
Hello Shrinivas, the problem you're having is that your textfield is not
returning a date object, is returning a String, so it is looking for the
setBirthday(String) as it says. I had the same problem and, at the end of
the day, i had to do this:

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); //change ot
with your patron
try{
  myDate = format.parse(birthdayFromTextbox);
}catch (ParseException e){}

hope it helps, I didn't find any other way to go

2011/8/18 Shrinivas Parashar <Sh...@symantec.com>

> Hi,
> I am getting following error if my model has a field of type
> java.util.Date. I am using struts 2.2.3. I have appropriate getter and
> setter method for birthday.
> JSP snippet:
>          <s:textfield name="user.birthday" label="Enter your birthday.
> (mm/dd/yy)"/>
>
> java.lang.NoSuchMethodException: setBirthday([Ljava.lang.String;)
>        at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1226)
>        at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1474)
>        at
> ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
>        at
> ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
>        at
> com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:27)
>        at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2245)
>        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)
>
> Regards,
> Shrinivas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Manolo Pájaro Santander
Ingeniero de Sistemas IX Semestre (Actual)
<<Promoviendo el Software Libre>>
CUSOL-UAC
Linux Registered User # 522026