You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Craig R. McClanahan" <Cr...@eng.sun.com> on 2001/01/11 18:48:55 UTC

Re: cvs commit: jakarta-struts/web/test html-multibox.jsp html-setters.jsp

"Kok, Arjan" wrote:

> Hello Craig,
>
> What happens if in the code snippet <html:text
> property="mailingAddress.street"/> mailingAddress is null? I would expect
> Struts not to raise an exception for initial display when mailingAddress is
> null, because Struts will also not raise an exception when street is null.
> If Struts raises an exception in the former, I would like an opportunity in
> Struts to check if there is a nested bean (e.g. by extending the
> logic:present tag).
>

Right now, Struts would throw an IllegalArgumentException ("Null property value
for 'mailingAddress'") if the mailingAddress property is null.

If mailingAddress is not null, but mailingAddress.street is null, a null will be
returned from PropertyUtils.getProperty(), which will ultimately display as a
zero length string in an <html:text> tag.

IMHO this is appropriate behavior.  It is up to the application designer to
ensure that all of the property values before the last one in a nested
expression are valid and non-null.  In Java terms, that means the tags expect
you to have initialized an Address with empty fields, and called
setMailingAddress() on your underlying bean, as part of the initial setup of the
"outer" bean.


>
> Arjan Kok.

Craig