Re: Nested Classes problem
This is a nested tags gotcha. I fell into it. I've seen lots of people fall into it. In fact there's alot of posts in the archives about it, which is probably why you didn't get a response til now, but essentially your problem is this: the nested beans turn to null between form presentation and submittal because they're in the request, so they only exist in your presentation call. You have to manually remake them for the submittal, or keep your form bean with the beans in it in your session. HTH Adam Matt Sales wrote: Hello, I'm having a problem nesting classes. I'll try to keep it simple: MyActionForm contains an instance of MyClass. MyClass contains an instance of MyNestedClass. When displaying values in a struts form, I can refer to the form property myClass.myNestedClass.id, and it displays the correct value. However, when I validate the form after a submit (either via MyActionForm or a cusom-built validate method in an Action class), a call to myClass.getMyNestedClass() returns null. All non-nested values are correct. If I un-nest myNestedClass and put it in MyActionForm bean, I have no problem... But it seems you should be able to nest classes and refer to those values... I don't know why a a nested class would turn to null between form presentation and submittal... Has anyone else had this problem? Thanks, Matt -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Nested Classes problem
Hello, I'm having a problem nesting classes. I'll try to keep it simple: MyActionForm contains an instance of MyClass. MyClass contains an instance of MyNestedClass. When displaying values in a struts form, I can refer to the form property myClass.myNestedClass.id, and it displays the correct value. However, when I validate the form after a submit (either via MyActionForm or a cusom-built validate method in an Action class), a call to myClass.getMyNestedClass() returns null. All non-nested values are correct. If I un-nest myNestedClass and put it in MyActionForm bean, I have no problem... But it seems you should be able to nest classes and refer to those values... I don't know why a a nested class would turn to null between form presentation and submittal... Has anyone else had this problem? Thanks, Matt -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Nested classes
Hi all, I am using an ActionForm with a collection of Rows which should be editable. My ActionForm contains a property getRow(int i) which returns a bean with the row's properties. Everything work perfectly, when the class returned from getRow(int) is a standalone class. But as soon as I make this class a nested class of my ActionForm, struts complains, if cannot find property setters: This works: public class MyForm ... { public MyRow getRow(int i) { ...; } } public class MyRow { public setProperty(String value) { ...; } } This does not: (cannot find property setter for row[0].property) public class MyForm ... { public MyRow getRow(int i) { ...; } public static class MyRow { public setProperty(String value) { ...; } } I'd really like to use nested classes. Is there a way? -- gR