Nested Classes problem

2002-07-09 Thread Matt Sales

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:   
For additional commands, e-mail: 




Re: Nested Classes problem

2002-07-10 Thread Adam Hardy

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:   
> For additional commands, e-mail: 
> 
> 



--
To unsubscribe, e-mail:   
For additional commands, e-mail: