Return-Path: Delivered-To: apmail-xml-cocoon-users-archive@xml.apache.org Received: (qmail 85534 invoked by uid 500); 2 Jun 2003 10:38:42 -0000 Mailing-List: contact cocoon-users-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-users@xml.apache.org Delivered-To: mailing list cocoon-users@xml.apache.org Received: (qmail 85518 invoked from network); 2 Jun 2003 10:38:36 -0000 Received: from unknown (HELO ddd.co.za) (196.22.97.194) by daedalus.apache.org with SMTP; 2 Jun 2003 10:38:36 -0000 Received: from guru.ddd.co.za ([10.0.0.13]) by ddd.co.za (JAMES SMTP Server 2.1) with SMTP ID 1002 for ; Mon, 2 Jun 2003 12:37:54 +0200 (SAST) Message-ID: <3EDB28D1.4080104@timberlake.co.za> Date: Mon, 02 Jun 2003 12:37:05 +0200 From: Andrew Timberlake User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: cocoon-users@xml.apache.org Subject: Re: create new Violation: xmlForm References: <20030531102957.14007.qmail@web41204.mail.yahoo.com> In-Reply-To: <20030531102957.14007.qmail@web41204.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hill Firstly, the error is in the line List list = null; You need to initialise the list to something. You are calling list.add(... in the following line. I use the following method: private List AddViolation(String path, String message) { Violation violation = new Violation(); violation.setPath(path); violation.setMessage(message); List list = getForm().getViolations(); if(list == null) list = new ArrayList(); list.add(0, violation); return list; } And then add the violation by calling the method: getForm().addViolations(AddViolation("/card", "New Error")); Hope this helps! Andrew Hill Karimov wrote: > Hi all, > > Question about xmlForm: > I want create new Violation and add it to Form. > What I do, here is snatch from my wizard action: > ... > public Map perform () { > VendorPhoneCard jBean = (VendorPhoneCard) > getForm().getModel(); > if ( ... some validation ... ) { > Violation newViolation = new Violation(); > newViolation.setMessage("New Error"); > newViolation.setPath("/card"); > List list = null; > list.add( newViolation ); > getForm().addViolations( list ); > } > if ( getForm().getViolations () != null && > !getFormView().equals( VIEW_CONFIRM ) ) { > ... > > I get : > java.lang.NullPointerException at > tsi.cocoon.xmlform.vendor.VendorProductWizardAction.perform(Unknown > Source) at > org.apache.cocoon.acting.AbstractXMLFormAction.act(AbstractXMLFormAction.java:265) > at > tsi.cocoon.xmlform.vendor.VendorProductWizardAction.act(Unknown > Source) at > org.apache.cocoon.components.treeprocessor.sitemap.ActTypeNode.invoke(ActTypeNode.java:139) > at > org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:84) > at > ... > > What is wrong? > > Any advises, help or tips, > Thanks a lot, > Hill > > > __________________________________ > Do you Yahoo!? > Yahoo! Calendar - Free online calendar with sync to Outlook(TM). > http://calendar.yahoo.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org > For additional commands, e-mail: cocoon-users-help@xml.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org For additional commands, e-mail: cocoon-users-help@xml.apache.org