Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 97181 invoked from network); 18 Jun 2004 06:47:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 18 Jun 2004 06:47:28 -0000 Received: (qmail 40377 invoked by uid 500); 18 Jun 2004 06:47:46 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 40348 invoked by uid 500); 18 Jun 2004 06:47:46 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: users@cocoon.apache.org Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 40320 invoked by uid 99); 18 Jun 2004 06:47:45 -0000 Received: from [157.193.121.51] (HELO otsrv1.iic.ugent.be) (157.193.121.51) by apache.org (qpsmtpd/0.27.1) with ESMTP; Thu, 17 Jun 2004 23:47:45 -0700 Received: from [192.168.123.100] (host100 [192.168.123.100]) by otsrv1.iic.ugent.be (8.11.6/8.11.6) with ESMTP id i5I5kbv12391 for ; Fri, 18 Jun 2004 07:46:37 +0200 Subject: Re: the widget datatype question From: Bruno Dumon To: users@cocoon.apache.org In-Reply-To: <012001c454fe$1d01cc60$5a0aa8c0@sony> References: <012001c454fe$1d01cc60$5a0aa8c0@sony> Content-Type: text/plain Organization: Outerthought Message-Id: <1087541134.21829.40.camel@yum> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 18 Jun 2004 08:46:18 +0200 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Fri, 2004-06-18 at 08:33, Johnson wrote: > Hi > > I try to caculate the widget value in repeter to another widget,the code is > > > test: > > > > > > amt: > > > > > repeater="daily1List" select="select"> > key="removeDaily1">removeDaily1: > > > var dList = event.source.parent.lookupWidget("daily1List"); > var testv=0; > > for (var i = 0; i < dList.size; i++) { > var row = dList.getRow(i); > num1 = row.lookupWidget("amt").value; > testv = testv + num1; > } > > var test = event.source.parent.lookupWidget("test"); > test.setValue(testv); > > > > > > If I had two row,one amt is 1,one amt is 2,the test will be "12",why. Probably because Javascript doesn't know about bigdecimals. Depending on your needs, you could change the datatype of the widget to float, double or long. If you need the precission of bigdecimal numbers, you need to use the methods of the BigDecimal class to do your calculations. See the javadoc of that class. It would be something like var testv = new Packages.java.math.BigDecimal("0"); testv = testv.add(num1); -- Bruno Dumon http://outerthought.org/ Outerthought - Open Source, Java & XML Competence Support Center bruno@outerthought.org bruno@apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org