Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 19195 invoked from network); 29 Jan 2005 00:20:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 29 Jan 2005 00:20:20 -0000 Received: (qmail 72390 invoked by uid 500); 29 Jan 2005 00:20:15 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 72346 invoked by uid 500); 29 Jan 2005 00:20:15 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 72327 invoked by uid 99); 29 Jan 2005 00:20:15 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of ksenji@gmail.com designates 64.233.184.192 as permitted sender) Received: from wproxy.gmail.com (HELO wproxy.gmail.com) (64.233.184.192) by apache.org (qpsmtpd/0.28) with ESMTP; Fri, 28 Jan 2005 16:20:14 -0800 Received: by wproxy.gmail.com with SMTP id 71so609483wri for ; Fri, 28 Jan 2005 16:20:12 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=Ihbo2vwsEfRy1c+YYLMneRN2xfMnIQNL6Z2hjc/L4Qeg3qaCxHZ1H7eUSQSU4vvExgiOrErLraz0BmbUQ9SgxS+45UtuSUUOV10QkdqqQAtL2xwy7VoafudF8Ij1gfczXhzCF/CC4H7kxyhA98Vw5vzHYObHOkKyjIpjVQ7oJNM= Received: by 10.54.22.74 with SMTP id 74mr37674wrv; Fri, 28 Jan 2005 16:19:44 -0800 (PST) Received: by 10.54.5.13 with HTTP; Fri, 28 Jan 2005 16:19:44 -0800 (PST) Message-ID: <38e8470105012816198c25ff0@mail.gmail.com> Date: Fri, 28 Jan 2005 16:19:44 -0800 From: Kishore Senji Reply-To: Kishore Senji To: Jakarta Commons Users List Subject: Re: [digester] How to set a LazyDynaBean map-of-objects property? In-Reply-To: <030f01c5056b$5ed58be0$030ea8c0@imbrium1> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <030f01c5056b$5ed58be0$030ea8c0@imbrium1> X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Fri, 28 Jan 2005 11:58:35 -0700, Wendy Smoak wrote: > I'm trying to set a mapped property of a LazyDynaBean. This is easy enough > if the Map is String/String, but I'm having trouble populating a Map where > the values are objects. > > Example XML: > > > Assuming a LazyDynaBean got created earlier > digester.addObjectCreate("download", LazyDynaBean.class); > > when I hit the tag, I create a DegreeViewImpl object and set its > properties from the tag attributes... > digester.addObjectCreate("download/person/degree", > DegreeViewImpl.class); > digester.addSetProperties("download/person/degree"); > > Now I need to pop the top object (the Degree) and call set( "degrees", key, > degree) on the LazyDynaBean. I need something like SetNextRule, but > SetNextRule only allows a single parameter to be passed to the method it is > told to call. > > At this point I believe I have a DegreeViewImpl object on the top of the > stack, and a LazyDynaBean just below it. (Though the log messages I'm > getting disagree.) It looks like CallMethodRule can be told to call its > method on an object further down the stack. I tried this: > > Rule rule = new CallMethodRule( -1, "set", 3); //also tried with > 1 instead of -1 > digester.addRule("/download/person/degree", rule); shouldn't the pattern be "download/person/degree" without the "/" in the beginning. Note 1 or -1 should both resolve in this case to the LazyDynaBean object stored on the stack. So, either one should work fine after removing the "/" in the pattern for the above line > digester.addObjectParam("download/person/degree", 0, "degrees"); > digester.addCallParam("download/person/degree", 1, "key"); > digester.addCallParam("download/person/degree", 2, true); > > But the CallMethodRule never happens, the logs show the ObjectParamRule > throwing a NPE, and complaining that the stack is empty. > > Digester - New match='download/person/degree' > ... skip setting all the properties of the DegreeImpl, which works ... > Digester - Fire begin() for ObjectParamRule[paramIndex=0, > attributeName=null, param=degrees] > Digester - Empty stack (returning null) > Digester - Begin event threw exception java.lang.NullPointerException > at > org.apache.commons.digester.ObjectParamRule.begin(ObjectParamRule.java:106) > > (The entire log output with the code and example xml is posted here: > http://wiki.wendysmoak.com/cgi-bin/wiki.pl?DigesterLazyDynaBean ) > > Does anyone see what I'm doing wrong? > > And what's the proper way to refer to the stack elements. If 0 is the top, > is the next one -1 or 1? > > Thanks, > Wendy Smoak > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-user-help@jakarta.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org