struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Gordon <adam.gor...@readytalk.com>
Subject Re: Indexed Bean Copy
Date Tue, 11 Jul 2006 15:24:24 GMT
Kiren-

I assume you mean BeanUtils.copyProperties(...) right?

If so, I believe the reason you cannot use it is because 
BeanUtils.copyProperties(...) performs a shallow copy and per the 
javadocs (HTML tags removed):  "...and so complex properties (for 
example, nested ones) will not be copied."

I would suggest removing it from the Action code by creating a utility 
class and implement your own copy() method.  Say, a static "duplication" 
method that takes an instance of your bean as a parameter and returns a 
new instance of the same bean.  I'm curious as to why you're using 
arrays as opposed to the Collections framework....

I don't believe that any copy methods in the J2SE are deep copy methods, 
so if this is what you need, then a static utility method is probably 
your best bet.

cheers,

-Adam

Pillay, Kiren KN wrote:
> Hi
>
> I've got a domain object which stored an indexed array of objects.
>
> <-- Extract of Domain Object
> public class GroupExposures {
>
> 	private Exposure [] exposures=new Exposure[]{new Exposure(),new
> Exposure(),new Exposure()};
> 	
> 	  
> 	class Exposure{
> 	float totalSBSABroughtForward;
> 	float otherSBSAFacilitiesPerParagraph;
> 	float SBSAExposureToTheApplicant;
> 	float otherSBGFacilitiesPerParagraph;
> 	float totalSBGExposureToTheApplicant;
> 	float otherSBSAFacilitesWholeGroup;
> 	float otherSBGFacilitiesWholeGroup;
> 	float totalSBGExposureWholeGroup;
> 	float SBGBorrowingsWholeGroup;
> 	float otherBankBorrowings;
> 	float otherLenders;
> 	float totalArrangedBorrowings;
> 	}
> 	
> public float getOtherLenders(int type) {
> 		return exposures[type].otherLenders;
> 	}
> 	public void setOtherLenders(float otherLenders,int type) {
> 		exposures[type].otherLenders = otherLenders;
> 	}
>
> -->
> Form extract:
> public float getOtherLendersUtilisation(){return
> OtherLendersUtilisation;
> 	}
>
> ----
>
> In my Action class I have to say the following:
>  
> groupExposures.setOtherLenders(groupExposuresForm.getOtherLendersUtilisa
> tion(),LimitTypes.UTILISATION);	
>  
>
> ------
> The way this class is set up, I cannot use BeanUtils.copy() to copy the
> values across. The Action class is huge because of this and it was quite
> tedious putting in the code. Is there a quicker, easier way to do this? 
>
> Regards
> Kiren Pillay
>
>
>
> ________________________________________________________________________
> __________________________________________________________
>
> Standard Bank Disclaimer and Confidentiality Note
>
> This e-mail, its attachments and any rights attaching hereto are, unless
> the context clearly indicates otherwise, the property of Standard Bank
> Group Limited
> and/or its subsidiaries ("the Group"). It is confidential, private and
> intended for the addressee only. Should you not be the addressee and
> receive this e-mail by
> mistake, kindly notify the sender, and delete this e-mail, immediately
> and do not disclose or use same in any manner whatsoever. Views and
> opinions
> expressed in this e-mail are those of the sender unless clearly stated
> as those of the Group. The Group accepts no liability whatsoever for any
> loss or
> damages whatsoever and howsoever incurred, or suffered, resulting, or
> arising, from the use of this email or its attachments. The Group does
> not warrant the integrity
> of this e-mail nor that it is free of errors, viruses, interception or
> interference. Licensed divisions of the Standard Bank Group are
> authorised financial services providers
> in terms of the Financial Advisory and Intermediary Services Act, No 37
> of 2002 (FAIS).
> For information about the Standard Bank Group Limited visit our website
> http://www.standardbank.co.za
> ________________________________________________________________________
> ___________________________________________________________
>
>   

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


Mime
View raw message