RE: Please Help! Nested form property attributes.

2003-01-06 Thread Paul Idusogie
I modified the formbean and action class to accept a date string and it work

Thanks Thanks Thanks.

Sincerely,


Paul Idusogie

Email: [EMAIL PROTECTED]
Tel: 651.714.8779


-Original Message-
From: Rick Reumann [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 06, 2003 12:42 PM
To: Struts Users Mailing List; [EMAIL PROTECTED]
Cc: Samir Shah
Subject: Re: Please Help! Nested form property attributes.




On Monday, January 6, 2003, 12:44:38 PM, Paul wrote:

PI> rootCause

PI> java.lang.IllegalArgumentException: argument type mismatch at
PI> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
PI>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
 

PI> What do I do?

enrollDate should be a String in your formBean. Are you sure you
aren't trying setting enrollDate as a Date type in your form bean?

I cc'd Samir as well, since I think he is having similar problems. I
think it's nice and clean to deal with Dates in forms this way:

1) Have a form bean with all Strings representing your jsp form. So
something like birthDate would be set up as a String.

2) Have a business bean with the correct data types. For example..
java.util.Date birthDate, double someNumber, etc.

3) When you submit your jsp page to your action you can take care of
the conversion of the FormBean(all Strings) to the correct data types
and populate your business bean (usually called a DTO or ValueObject).
Similarly, when going the other direction you can take a business bean
and convert the Date fields into Strings (with the format you like)
and populate your FormBean and display that to the user.

As far as doing the conversion I usually take care of that outside of
the Action and use the BeanUtils.copyProperties(..) but you can also
just create your own helper class to do the conversions for you if you
like.


--

Rick
mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Please Help! Nested form property attributes.

2003-01-06 Thread Rick Reumann


On Monday, January 6, 2003, 12:44:38 PM, Paul wrote:

PI> rootCause

PI> java.lang.IllegalArgumentException: argument type mismatch at
PI> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
PI> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
 

PI> What do I do?

enrollDate should be a String in your formBean. Are you sure you
aren't trying setting enrollDate as a Date type in your form bean?

I cc'd Samir as well, since I think he is having similar problems. I
think it's nice and clean to deal with Dates in forms this way:

1) Have a form bean with all Strings representing your jsp form. So
something like birthDate would be set up as a String.

2) Have a business bean with the correct data types. For example..
java.util.Date birthDate, double someNumber, etc.

3) When you submit your jsp page to your action you can take care of
the conversion of the FormBean(all Strings) to the correct data types
and populate your business bean (usually called a DTO or ValueObject).
Similarly, when going the other direction you can take a business bean
and convert the Date fields into Strings (with the format you like)
and populate your FormBean and display that to the user.

As far as doing the conversion I usually take care of that outside of
the Action and use the BeanUtils.copyProperties(..) but you can also
just create your own helper class to do the conversions for you if you
like.


-- 

Rick
mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Please Help! Nested form property attributes.

2003-01-06 Thread Paul Idusogie
Please Help!

I have the following code snippet in a jsp page


.










.


The attribute user.enrollDate is an attribute of the user class used a the
profileForm formBean.
I have a calendar object that permits the selection and population of the
user.enrollDate field with a date.

When I click the submit button on the page I receive a
document.profileForm.user.enrollDate is null or not an object. The generated
page does not accept the reference to an nested attribute user.enrollDate.



So I created an attribute within the formbean called enrollDate and in the
setproperty method, I set the user.enrollDate to this property. The revised
jsp page looks like this


.










.



When I click the submit button on the jsp page I receive the following
exception:

javax.servlet.ServletException:
BeanUtils.populate at
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:980) at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j
ava:779) at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:246)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
 .

rootCause

java.lang.IllegalArgumentException: argument type mismatch at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.j
ava:1650) at
org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.j
ava:1545) at
org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:15
74) at
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:919) at
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:726) at
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:978) at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j
ava:779) at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:246)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
...

What do I do?

Sincerely,


Paul Idusogie

Email: [EMAIL PROTECTED]
Tel: 651.714.8779


--
To unsubscribe, e-mail:   
For additional commands, e-mail: