Hi all,
What is the best strategy to submit Date objects from html forms using struts framework?. When I have a FormBean with a Date property. The struts API cann't populate this Bean, dispatching the following error:
java.lang.IllegalArgumentException: argument type mismatch
...
org.apache.struts.util.PropertyUtils.setSimpleProperty(PropertyUtils.java:988)
I'll appreciate your help.
Cesar.
Discussions
Web tier: servlets, JSP, Web frameworks: Submiting Date Objects in html forms using struts
-
Submiting Date Objects in html forms using struts (3 messages)
- Posted by: julio rincon
- Posted on: December 17 2002 14:41 EST
Threaded Messages (3)
- Submiting Date Objects in html forms using struts by Web Master on December 17 2002 15:08 EST
- Submiting Date Objects in html forms using struts by julio rincon on December 17 2002 15:56 EST
- Submiting Date Objects in html forms using struts by Web Master on December 17 2002 06:09 EST
- Submiting Date Objects in html forms using struts by julio rincon on December 17 2002 15:56 EST
-
Submiting Date Objects in html forms using struts[ Go to top ]
- Posted by: Web Master
- Posted on: December 17 2002 15:08 EST
- in response to julio rincon
The page isnt actually submitting a Date object, but a String object that represents a date. Its just a HTTP parameter being passed.
Struts will populate your FormBean with that String and then your FormBean can validate it and convert it to a Date object. -
Submiting Date Objects in html forms using struts[ Go to top ]
- Posted by: julio rincon
- Posted on: December 17 2002 15:56 EST
- in response to Web Master
Thanks!,
That means that I cann't have a FormBean like this, can I?:
public class MyFormBean extends ActionForm{
private Date myDateField;
...
public void setMyDateField(Date date){
myDateField = date;
}
...
}
Instead, Should I have allways String propeties?. like this:
public class MyFormBean extends ActionForm{
private Date myDateField;
...
public void setMyDateField(String date){
myDateField = convertToDate(date);
}
...
}
Am I right?...
Thanks for your help. -
Submiting Date Objects in html forms using struts[ Go to top ]
- Posted by: Web Master
- Posted on: December 17 2002 18:09 EST
- in response to julio rincon
Right. No data type conversions are performed in v1.0 and Im pretty sure that hasnt changed in v1.1. Dont hold me to that though.
The jakarta commons beanutils package is used in v1.1 and the PropertyUtils class your using has been deprecated.