You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by mi...@ps.ge.com on 2003/04/10 20:01:21 UTC

how to use BeanUtil.copyProperty() ?

Hello,

I have a Model (VO) that has diff types of fields like a int, String, List,
etc.
a Form has just Strings and Lists

the BeanUtil.copyProperty() returns an error - it can't "cast" int to String
and vs

would some one give me an example how to use it right? pls.

Best Regards.
Michael.


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


Re: how to use BeanUtil.copyProperty() ?

Posted by Vinay <vi...@mdp.net>.
As far as I know I think both the form and the bean should have same number
of attributes and datatypes.

I have example

 RPInfo rp=new RPInfo();
  BeanUtils.copyProperties(rp,(DynaValidatorActionForm) form);


Where form has same number of attribute and the same kind of corresponding
data types


 /* RP Value Object Class ------------------------------------------------*/
package net.mdp.rp.model;

import java.sql.*;
import java.io.*;
import java.util.*;

public class RPInfo {

    private String acctno;
    private String ptfname;
    private String ptmname;
    private String ptlname;
    public RPInfo()  {
     clear();
    }

    public void clear() {
  acctno="";
        ptfname="";
     ptmname="";
     ptlname="";
    }

    public void setAcctno(String acctno) {
  this.acctno=acctno;
    }

    public String getAcctno()  {
  return acctno;
    }

    public void setPtfname(String ptfname) {
    this.ptfname=ptfname;
    }

    public String getPtfname()  {
  return ptfname;
    }

    public void setPtmname(String ptmname)  {
  this.ptmname=ptmname;
    }

    public String getPtmname()  {
  return ptmname;
    }

    public void setPtlname(String ptlname)  {
  this.ptlname=ptlname;
    }

    public String getPtlname()  {
  return ptlname;
    }

    public static void main(String[] args) {
     RPInfo ri = new RPInfo();
    }
}


Let know if this is not clear
vinay
----- Original Message -----
From: <mi...@ps.ge.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, April 10, 2003 2:01 PM
Subject: how to use BeanUtil.copyProperty() ?


> Hello,
>
> I have a Model (VO) that has diff types of fields like a int, String,
List,
> etc.
> a Form has just Strings and Lists
>
> the BeanUtil.copyProperty() returns an error - it can't "cast" int to
String
> and vs
>
> would some one give me an example how to use it right? pls.
>
> Best Regards.
> Michael.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>



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