That's sound design advice, and I certainly may end up doing that. I guess right now I'm more interested in finding out if there's a Struts way to do this, in order to understand all the facets of Struts better.
Cheers, David -----Original Message----- From: Struts Newsgroup [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 01, 2002 3:55 PM To: [EMAIL PROTECTED] Subject: Re: How to access nested properties which may be null? Subject: Re: How to access nested properties which may be null? From: Vic Cekvenich <[EMAIL PROTECTED]> === It might be that you are doing a bit more in JSP than you should. More should be done in the model. In action, you should check conditions. Vic [EMAIL PROTECTED] wrote: > Hello, > > > > How do I use, say, the <bean:write> tag to print out the value of a nested > property, if there's a possibility that the parent of the nested property > may be Null? > > > > I have a User bean with method getAuthorityLevel which returns an instance > of the AuthorityLevel bean. The AuthorityLevel bean then has a method > getName, which returns a string. I have something like this in my JSP: > > > > <bean:write name="myUser" property="authorityLevel.name"/> > > > > This works fine if the User bean in the "myUser" variable has an > AuthorityLevel, but if it does not then getAuthorityLevel returns Null, and > Struts then throws a NullPointerException. Is there a simple way around > this? > > > > Do the "Nested Tags" address this situation? > > > > Thanks! > > David > > > > David A. Ventimiglia > > Wells Fargo Private Client Services > > (415) 396-0414 (work) > > > > -- 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]>

