You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Juan Alvarado (Struts List)" <ju...@manduca.com> on 2002/06/12 17:15:40 UTC
Problem with PropertyUtils.copyProperties(...
I am using a DynaActionForm:
<form-bean name="userForm"
dynamic="true"
type="org.apache.struts.validator.DynaValidatorForm" >
<form-property name="id" type="java.lang.String"/>
<form-property name="firstName" type="java.lang.String"/>
<form-property name="lastName" type="java.lang.String"/>
<form-property name="dispatch" type="java.lang.String"/>
</form-bean>
I want to perform the following in my action:
DynaActionForm f = (DynaActionForm)form;
User user = new User();
try{
PropertyUtils.copyProperties(user, f);
}
catch(Exception e){...}
My user object is composed as follows:
package ob.users;
public class UserDTO {
private String firstName;
private String lastName;
private Integer id;
public java.lang.String getFirstName() {
return firstName;
}
public Integer getId() {
return id;
}
public java.lang.String getLastName() {
return lastName;
}
public void setFirstName(java.lang.String value) {
firstName = value;
}
public void setId(Integer value) {
id = value;
}
public void setLastName(java.lang.String value) {
lastName = value;
}
}
And I keep on getting Error creating DTO -- java.lang.NoSuchMethodException:
Unknown property 'class'
I am relatively new using the bean utils package and I didn't find anything
in the archives. Can anyone tell me what I'm doing wrong.
Thanks in advance
**********************************************
Juan Alvarado
Internet Developer -- Manduca Management
(786)552-0504
jalvarado@manduca.com
AOL Instant Messenger: juan2000@aol.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Problem with PropertyUtils.copyProperties(...
Posted by Rick Reumann <ma...@reumann.net>.
Juan,
I think I made a mistake (sort of) when I shared some of this code. I
didn't realize you don't need the dispatch field (or whatever you want
to name it) in the actual DynaActionForm or an ActionForm. I notice
that the UserDTO doesn't have the dispatch member in it, so maybe the
PropertyUtils is looking for to convert that field from the
DynaActionForm? (Not sure though just a guess since I haven't used
PropertyUtils ). Try just removing the
<form-property name="dispatch" type="java.lang.String"/>
from the DyanActionForm and see what happens.
Rick
On Wednesday, June 12, 2002, 11:15:40 AM, Juan wrote:
JASL> I am using a DynaActionForm: <form-bean name="userForm"
JASL> dynamic="true"
JASL> type="org.apache.struts.validator.DynaValidatorForm" >
JASL> <form-property name="id" type="java.lang.String"/>
JASL> <form-property name="firstName" type="java.lang.String"/>
JASL> <form-property name="lastName" type="java.lang.String"/>
JASL> <form-property name="dispatch" type="java.lang.String"/>
JASL> </form-bean>
JASL> I want to perform the following in my action:
JASL> DynaActionForm f = (DynaActionForm)form;
JASL> User user = new User();
JASL> try{
JASL> PropertyUtils.copyProperties(user, f);
JASL> }
JASL> catch(Exception e){...}
JASL> My user object is composed as follows:
JASL> package ob.users;
JASL> public class UserDTO {
JASL> private String firstName;
JASL> private String lastName;
JASL> private Integer id;
JASL> public java.lang.String getFirstName() {
JASL> return firstName;
JASL> }
JASL> public Integer getId() {
JASL> return id;
JASL> }
JASL> public java.lang.String getLastName() {
JASL> return lastName;
JASL> }
JASL> public void setFirstName(java.lang.String value) {
JASL> firstName = value;
JASL> }
JASL> public void setId(Integer value) {
JASL> id = value;
JASL> }
JASL> public void setLastName(java.lang.String value) {
JASL> lastName = value;
JASL> }
JASL> }
JASL> And I keep on getting Error creating DTO -- java.lang.NoSuchMethodException:
JASL> Unknown property 'class'
JASL> I am relatively new using the bean utils package and I didn't find anything
JASL> in the archives. Can anyone tell me what I'm doing wrong.
JASL> Thanks in advance
JASL> **********************************************
JASL> Juan Alvarado
JASL> Internet Developer -- Manduca Management
JASL> (786)552-0504
JASL> jalvarado@manduca.com
JASL> AOL Instant Messenger: juan2000@aol.com
JASL> --
JASL> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
JASL> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
Rick
mailto:maillist@reumann.net
"I wish I had a dollar for every time I spent a dollar, because then,
Yahoo!, I'd have all my money back."
-Jack Handey
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>