You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Henry Lu <zh...@umich.edu> on 2002/02/02 21:05:17 UTC

PropertyUtils.copyProperties function

It seems to me that PropertyUtils.copyProperties doesn't work properly.
Could anyone show me how it works? The following is my code and output:
//////////////////////////////////////////////////////////////////
      RegForm theRegForm = (RegForm)form;
      Student stdt = (Student)session.getAttribute("student");
      Address addr = (Address)session.getAttribute("address");

      if (stdt == null) {
System.out.println("\tStudent null!!!");
      }

      try {
System.out.println("\tid="+theRegForm.getId());
System.out.println("\tcity="+theRegForm.getCity());
         PropertyUtils.copyProperties(theRegForm, stdt);
         PropertyUtils.copyProperties(theRegForm, addr);

System.out.println("\tid="+stdt.getId());
System.out.println("\tcity="+addr.getCity());
      } catch (Exception e) {
System.out.println("\t"+e.toString());
      }

/////////////////////////////////////
output:
id=123
city=Ann Arbor
id=null
city=null


---------------------------------------------------------------------------
Henry Lu
MCIT                                            phone: (734) 936-2063
University of Michigan Medical Center           fax:   (734) 763-4372


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>