RE: question on DynaActionForm
Jim, I'm not exactly sure what the book means when they say that whether you use an ActionForm or a DynaActionForm should be transparent, but once you use DynaActionForm, you form is no longer of type RegisterForm (hence the ClassCastException). You must cast it to DynaActionFrom now as in: DynaActionFrom rf = (DynaActionForm) form; Also, you will need to access the data in rf differently now... rf.get(Name of property); -Jonathan -Original Message- From: Anderson, James H [IT] [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 9:52 AM To: Struts Users Mailing List Subject: question on DynaActionForm I'm trying to modify the simple Register application from Chapter 1 of Struts in Action to use a DynaActionForm in place on the ActionForm shown in the book. I've modified struts-config.xml accordingly. According to the book, whether you use an ActionForm or a DynaActionForm should be transparent. However, when I attempt to run the modified app I get a ClassCastException at the following line in RegisterAction.java: RegisterForm rf = (RegisterForm) form; I'm sure it's something dumb, but I'm not seeing it. Any help appreciated. Thanks, jim - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: question on DynaActionForm
Thanks! That did it. So, unless I read it wrong, the statement regarding transparency was in error. Thanks again. jim -Original Message- From: Fullam, Jonathan [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 9:58 AM To: 'Struts Users Mailing List' Subject: RE: question on DynaActionForm Jim, I'm not exactly sure what the book means when they say that whether you use an ActionForm or a DynaActionForm should be transparent, but once you use DynaActionForm, you form is no longer of type RegisterForm (hence the ClassCastException). You must cast it to DynaActionFrom now as in: DynaActionFrom rf = (DynaActionForm) form; Also, you will need to access the data in rf differently now... rf.get(Name of property); -Jonathan -Original Message- From: Anderson, James H [IT] [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 9:52 AM To: Struts Users Mailing List Subject: question on DynaActionForm I'm trying to modify the simple Register application from Chapter 1 of Struts in Action to use a DynaActionForm in place on the ActionForm shown in the book. I've modified struts-config.xml accordingly. According to the book, whether you use an ActionForm or a DynaActionForm should be transparent. However, when I attempt to run the modified app I get a ClassCastException at the following line in RegisterAction.java: RegisterForm rf = (RegisterForm) form; I'm sure it's something dumb, but I'm not seeing it. Any help appreciated. Thanks, jim - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Question about DynaActionForm
Ok, I fount what was causing the problem. Turns out that I was missing a 'public' modifier on the Person constructor class which prevented the Struts FormPropertyConfig class to call create a new instance of Person. In MHO it should have printed something to the log instead of swallowing the error. I still would be happy to hear your opinion on my second question - how to add properties in a DynaActionForm derived class. Thanks, Erez -Original Message- From: Erez Efrati [mailto:[EMAIL PROTECTED] Sent: Monday, September 01, 2003 10:20 PM To: 'Struts Users Mailing List' Subject: Question about DynaActionForm I am trying to do the following test form: form-bean name=TestDynaForm type=org.apache.struts.validator.DynaValidatorForm form-property name=method type=java.lang.String / form-property name=page type=java.lang.Integer / form-property name=person type=web.Person / /form-bean In my Action I get the person member = NULL. 1) Is it forbidden to use normal Objects embedded inside a DynaForm? 2) Is it possible to extend a DyaActionForm and have the Derived class insert new properties on the fly, things like 'method' 'page' etc..? Thanks in advance, Erez - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Question about DynaActionForm
Hi Erez Things should work as they are and nesting beans in dynaforms works fine. I have no idea about the logging, yes and things can get a little hard to drill down to where the beef is. You'll have to explain what you mean by DynaActionForm derived class? Cheers Mark On Monday, September 1, 2003, at 09:42 PM, Erez Efrati wrote: Ok, I fount what was causing the problem. Turns out that I was missing a 'public' modifier on the Person constructor class which prevented the Struts FormPropertyConfig class to call create a new instance of Person. In MHO it should have printed something to the log instead of swallowing the error. I still would be happy to hear your opinion on my second question - how to add properties in a DynaActionForm derived class. Thanks, Erez -Original Message- From: Erez Efrati [mailto:[EMAIL PROTECTED] Sent: Monday, September 01, 2003 10:20 PM To: 'Struts Users Mailing List' Subject: Question about DynaActionForm I am trying to do the following test form: form-bean name=TestDynaForm type=org.apache.struts.validator.DynaValidatorForm form-property name=method type=java.lang.String / form-property name=page type=java.lang.Integer / form-property name=person type=web.Person / /form-bean In my Action I get the person member = NULL. 1) Is it forbidden to use normal Objects embedded inside a DynaForm? 2) Is it possible to extend a DyaActionForm and have the Derived class insert new properties on the fly, things like 'method' 'page' etc..? Thanks in advance, Erez - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]