DynaValidatorActionForm Setting Properties
I have an Action to prepare a JSP view which uses a DynaValidatorActionForm. When i try to set a Form property i get a NullPointerException my source is as follows: - Struts-Config.xml - form-bean name=MyForm type=org.apache.struts.action.DynaValidatorActionForm form-property name=myTestTO type=com.mycompany.to.myTestTO/ /form-bean action path=/viewTest type=com.mycompany.actions.myTestAction scope=request input=my-tile-view name=MyForm validate=false forward name=success path=success-tile/ /action -- VALIDATION.xml -- form-validation formset form name=MyForm field property=myTestTO.name depends=required,minlength var var-nameminlength/var-name var-value10/var-value /var /field /form /formset /form-validation -- ACTION SOURCE CODE (i.e. com.mycompany.actions.myTestAction) -- DynaValidatorActionForm myForm = new DynaValidatorActionForm(); myForm.set(myTestTO, new myTestTO()); /* THROWS NullPointerException Here*/ pRequest.setAttribute(MyForm, myForm ); I've also tried casting the inbound ActionForm to DynaValidatorActionForm but i still get the same error when i invoke the set method. Any Ideas? _ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DynaValidatorActionForm Setting Properties
Hi Pat, if you have to instantiate it yourself, you should call the initialize() method on the form first so that struts configures it to the struts-config settings. However that probably won't help in this case since your in-bound form doesn't work either. I doubt it would help, but you could try naming your class with an initial capitalized letter. Secondly, does the exception from the inbound form have a message? Regards Adam On 09/29/2003 01:35 PM Pat Quinn wrote: I have an Action to prepare a JSP view which uses a DynaValidatorActionForm. When i try to set a Form property i get a NullPointerException my source is as follows: - Struts-Config.xml - form-bean name=MyForm type=org.apache.struts.action.DynaValidatorActionForm form-property name=myTestTO type=com.mycompany.to.myTestTO/ /form-bean action path=/viewTest type=com.mycompany.actions.myTestAction scope=request input=my-tile-view name=MyForm validate=false forward name=success path=success-tile/ /action -- VALIDATION.xml -- form-validation formset form name=MyForm field property=myTestTO.name depends=required,minlength var var-nameminlength/var-name var-value10/var-value /var /field /form /formset /form-validation -- ACTION SOURCE CODE (i.e. com.mycompany.actions.myTestAction) -- DynaValidatorActionForm myForm = new DynaValidatorActionForm(); myForm.set(myTestTO, new myTestTO()); /* THROWS NullPointerException Here*/ pRequest.setAttribute(MyForm, myForm ); I've also tried casting the inbound ActionForm to DynaValidatorActionForm but i still get the same error when i invoke the set method. Any Ideas? _ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 4.1.27 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DynaValidatorActionForm Setting Properties
Hi Adam, Cheers for your efforts turns out it a silly mistake i've made i.e. i entered an invalid class name for my form defintion i.e. form-bean name=MyForm type=org.apache.struts.action.DynaValidatorActionForm Should be: form-bean name=MyForm type=org.apache.struts.validator.DynaValidatorActionForm Casting the inbound action form now works fine. Cheers Pat From: Adam Hardy [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: DynaValidatorActionForm Setting Properties Date: Mon, 29 Sep 2003 14:19:20 +0200 Hi Pat, if you have to instantiate it yourself, you should call the initialize() method on the form first so that struts configures it to the struts-config settings. However that probably won't help in this case since your in-bound form doesn't work either. I doubt it would help, but you could try naming your class with an initial capitalized letter. Secondly, does the exception from the inbound form have a message? Regards Adam On 09/29/2003 01:35 PM Pat Quinn wrote: I have an Action to prepare a JSP view which uses a DynaValidatorActionForm. When i try to set a Form property i get a NullPointerException my source is as follows: - Struts-Config.xml - form-bean name=MyForm type=org.apache.struts.action.DynaValidatorActionForm form-property name=myTestTO type=com.mycompany.to.myTestTO/ /form-bean action path=/viewTest type=com.mycompany.actions.myTestAction scope=request input=my-tile-view name=MyForm validate=false forward name=success path=success-tile/ /action -- VALIDATION.xml -- form-validation formset form name=MyForm field property=myTestTO.name depends=required,minlength var var-nameminlength/var-name var-value10/var-value /var /field /form /formset /form-validation -- ACTION SOURCE CODE (i.e. com.mycompany.actions.myTestAction) -- DynaValidatorActionForm myForm = new DynaValidatorActionForm(); myForm.set(myTestTO, new myTestTO()); /* THROWS NullPointerException Here*/ pRequest.setAttribute(MyForm, myForm ); I've also tried casting the inbound ActionForm to DynaValidatorActionForm but i still get the same error when i invoke the set method. Any Ideas? _ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 4.1.27 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]