Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 41359 invoked from network); 2 Jun 2005 19:46:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Jun 2005 19:46:25 -0000 Received: (qmail 75613 invoked by uid 500); 2 Jun 2005 19:46:18 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 75600 invoked by uid 500); 2 Jun 2005 19:46:18 -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 List-Id: Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 75556 invoked by uid 99); 2 Jun 2005 19:46:17 -0000 X-ASF-Spam-Status: No, hits=0.4 required=10.0 tests=DNS_FROM_RFC_ABUSE,RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of owen.tallman@gmail.com designates 64.233.162.205 as permitted sender) Received: from zproxy.gmail.com (HELO zproxy.gmail.com) (64.233.162.205) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 02 Jun 2005 12:46:13 -0700 Received: by zproxy.gmail.com with SMTP id 18so690293nzp for ; Thu, 02 Jun 2005 12:46:05 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=jqJttp1w8VIlSq4JtNPCcKsfjf2fiz1JsHDnFr9RqEbiA3xRPhn8303isJTXgmfWWrZf0aGbclWIB290jKUoWeb358OHmARdw8CsR9gBey0H/VC47T5hNyslFti3mYyh7CrQIGLUpcz7LAIzFcJqo17OAhUQbDnlNRYZTkQ2cc8= Received: by 10.36.36.18 with SMTP id j18mr611108nzj; Thu, 02 Jun 2005 12:46:05 -0700 (PDT) Received: by 10.36.97.12 with HTTP; Thu, 2 Jun 2005 12:46:05 -0700 (PDT) Message-ID: Date: Thu, 2 Jun 2005 15:46:05 -0400 From: Owen Tallman Reply-To: owen.tallman@acm.org To: users@cocoon.apache.org Subject: problem with enum and CForms selection-list Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I've followed the examples and advice I've been able to find and can't get past this problem. I want to use a typesafe enum to populate the fields of a selection-list in my form. I modelled it after the Sex enum in the form2* example. Things proceed to the point of calling form.load(bean) in my flowscript, and I get this stack trace: java.lang.NullPointerException =09at org.apache.cocoon.forms.datatype.typeimpl.EnumType.getTypeClass(EnumT= ype.java:55) =09at org.apache.cocoon.forms.formmodel.Field.setValue(Field.java:161) =09at org.apache.cocoon.forms.binding.ValueJXPathBinding.doLoad(ValueJXPath= Binding.java:103) =09at org.apache.cocoon.forms.binding.JXPathBindingBase.loadFormFromModel(J= XPathBindingBase.java:162) =09at org.apache.cocoon.forms.binding.ComposedJXPathBindingBase.doLoad(Comp= osedJXPathBindingBase.java:96) =09at org.apache.cocoon.forms.binding.ContextJXPathBinding.doLoad(ContextJX= PathBinding.java:52) =09at org.apache.cocoon.forms.binding.JXPathBindingBase.loadFormFromModel(J= XPathBindingBase.java:162) =09at org.apache.cocoon.forms.binding.JXPathBindingBase.loadFormFromModel(J= XPathBindingBase.java:176) =09at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) =09at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.= java:39) =09at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces= sorImpl.java:25) =09at java.lang.reflect.Method.invoke(Method.java:324) =09at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:23= 0) =09at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244) =09at org.mozilla.javascript.continuations.ContinuationInterpreter.interpre= t(ContinuationInterpreter.java:1134) =09at org.mozilla.javascript.continuations.ContinuationInterpreter.interpre= t(ContinuationInterpreter.java:190) =09at org.mozilla.javascript.continuations.ContinuationInterpreter.interpre= t(ContinuationInterpreter.java:138) =09at org.mozilla.javascript.continuations.InterpretedFunctionImpl.call(Int= erpretedFunctionImpl.java:121) =09at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244) =09at org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterp= reter.callFunction(FOM_JavaScriptInterpreter.java:755) =09at org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.i= nvoke(CallFunctionNode.java:135) ... and so on Here's the form definition. The part that breaks occurs near the end: =09 Select All Clear All java.lang.System.err.println("Clear All!"); = =20 event.source.value =3D false; =09=09 =09=09=09 =09=09=09=09 =09=09=09=09 =09=09=09=09=09 =09=09=09=09 =09=09=09=09 =09=09=09=09=09 =09=09=09=09 =09=09=09=09 =09=09=09=09=09 =09=09=09=09 =09=09=09=09 =09=09=09=09=09 =09=09=09=09 =09=09=09=09 =09=09=09=09=09 =09=09=09=09 =09=09=09 =09=09 Select locations to search: com.envisn.nv.form.enums.LocationType =09 The binding looks like this: =09 =09 =09=09 =09=09=09 =09=09 =09=09 =09=09 =09=09=09 =09=09=09 =09=09=09 =09=09=09 =09=09 =09 The enum class looks like this (actually it pretty much contains the "Sex" code now, as I wanted to eliminate as many variables in the comparison as possible: public class LocationType { public static final LocationType MALE =3D new LocationType("M"); public static final LocationType FEMALE =3D new LocationType("F"); public static final LocationType ANY =3D new LocationType("A"); private String code; private LocationType(String code) { this.code =3D code; } public String toString() { // Will probably have some i18n support here switch(code.charAt(0)) { case 'M' : return this.getClass().getName() + ".MALE"; case 'F' : return this.getClass().getName() + ".FEMALE"; case 'A' : return this.getClass().getName() + ".ANY"; default : return "unknown"; // Should never happen } } } and the bean class that it loads looks like this: public class PackageAnalysisFormBean { private Collection targets =3D new ArrayList(); private LocationType locationType =3D LocationType.ANY ; public Collection getTargets() { return targets; } public void setTargets(Collection targets) { this.targets =3D targets;= } public void addTarget(LookupInfo lookupInfo) {=20 this.targets.add(lookupInfo); } public LocationType getLocationType() { return locationType; } public void setLocationType(LocationType locationType) { this.locationType =3D locationType; } } Finally the flowscript. It uses a factory class to do a query and populate the bean. That all worked fine prior to introducing the enum for the selection-list:: -------- function do_packageAnalysis(form) { var userSession =3D outerSession.getAttribute(userSessionKey) ; var bean =3D Packages.com.envisn.nv.form.WidgetFactory.getPackageAnalys= isForm(userSession); var targets =3D bean.getTargets().toArray() ; form.load(bean); --------- and it blows up there. Everything worked fine in the earlier version with static selection definitions. I have traced this as far as I can with logging, and the bean's methods get called during the form load, and return legitimate references. I'd appreciate any hints about what might have gone wrong here. Thanks Owen --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org