Why don't you just override the equals method in your bean class?
public boolean equals(Object o) {
if (!(o instanceof MyClass)) return false;
MyClass bean = (MyClass) o;
if (!(name.equals(bean.name))) return false;
if (!(sex.equals(bean.sex))) return false;
//etc. . .
return true;
}
Then you can just ask:
if (bean1.equals(bean2))
Erik
O. Oke wrote:
Please, I want find out if the value of each of the matching properties in two beans are the same.
BACKGROUND
========== I have two JAVABEANS A AND B. They both have name and
sex properties amongst others. I want to find out if
A.name == B.name and A.sex == B.sex.
Is there any method in Struts that is designed to do
this type of comparison? i.e. int objName.compareJavaBeans(javaBean1, javaBean2)
Presently, I am doing this:
String beanBk = customerBeanBk.getCustomerNo()+ customerBeanBk.getFirstName() +
customerBeanBk.getLastName();
...
String beanDbCp = customerBeanDbCp.getCustomerNo() + customerBeanDbCp.getFirstName() + customerBeanDbCp.getLastName(); ... if (beanBk.equals(beanDbCp)){ ..... }
Thank you
___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]