Erik's answer is what I would call the correct one... That being said, if
for some reason you don't want to use that approach, I don't think there's
anything specifically in Struts to do what you want anyway, but you might
want to have a look through the Commons BeanUtils packages.  If such a
thing exists, I'd bet on it being there.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Sun, September 19, 2004 6:47 pm, Erik Weber said:
> 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]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to