You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Hill Karimov <hi...@yahoo.com> on 2003/05/31 12:29:57 UTC
create new Violation: xmlForm
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
Re: create new Violation: xmlForm
Posted by Hill Karimov <hi...@yahoo.com>.
Yes it works.
Thanks.
One more thing:
What about if no path, i.e. if violation for all form
not only one object.
Can I use empty path, or there is correct way?
getForm().addViolations( AddViolation("/", "new
Error") );
Thanks a lot.
Hill
--- Andrew Timberlake <an...@timberlake.co.za> wrote:
> 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
>
__________________________________
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
Re: create new Violation: xmlForm
Posted by Andrew Timberlake <an...@timberlake.co.za>.
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