|
From: Ahmed A. <sne...@gm...> - 2005-11-01 07:59:14
|
hey guys how can i validate array of data dynamically(the array is created
dynamically by
javascript) knowing that i get error every time saying that it is not a
binded object and it is a
string (the object i am trying to validate it)
the error i get is : java.lang.ClassCastException: java.lang.String
and the validation code that i used to validate the dynamic list is like
this :
private void validateEquality(PaymentDocument document,
Errors errors) {
Long amount=3Ddocument,.getAmount();
Long Sum=3Dnew Long(0);
//where Financialtransactiondetails is the list that contains the dynamic
data
Iterator itr=3Ddocument,.getFinancialtransactiondetails().ite rator();
while(itr.hasNext())
{
Object currenct=3Ditr.next();
Long cashAmount =3D new Long(((FinancialTransactionDetails)currenct).getAm
ount());
log.debug(">>>>>>>>>>>>>>>>>>> cashAmount "+cashAmount);
Sum+=3DcashAmount;
}
//if the sum of all the money =3D the amount that the user entered then eve=
ry
thing is good else i will raise an error
if(!Sum.equals(amount))
errors.rejectValue("amount","Error In Amount","Total Amount Must Be Equal T=
o
Details Amount");
}
--------------------------------------------------END OF
VALIDATION-----------------------------------------------
*when i enter a wrong amount then i will be prompeted to enter the correct
amount(that is right) and when i enter the correct amount (just to correct
the wrong amount i entred before) i get the CLASS CAST EXCEPTION , if i
entred it correct from the 1st time everything will work just fine......wel=
l
got any idea
<http://forum.springframework.org/editpost.php?do=3Deditpost&p=3D38945>
|