struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip Hart" <har...@ubusiness.co.uk>
Subject RE: can a ActionForm be ever null in Action class
Date Fri, 02 Feb 2001 20:47:48 GMT
Hi All

Just a thought, but couldn't we use the Null Object pattern (pp 365-369,
Patterns in Java Volume 1, Mark Grand) as a default for this scenario?

It would mean that there would be no further need to make an explicit test
for null, as calling the corresponding method will have no effect.

As I said, just a thought. In any case, keep up the brilliant work.


Cheers,
Philip Hart

> -----Original Message-----
> From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com]
> Sent: 02 February 2001 17:42
> To: struts-user@jakarta.apache.org
> Subject: Re: can a ActionForm be ever null in Action class
>
>
> Anand Raman wrote:
>
> > Hi guys
> >
> > I noticed in the struts-example application a check to find whether the
> > ActionForm "form" passed to the perform method of Action class
> is null or
> > not.
> >
> > Is it really necesarry.. I am not able to come up with a situation like
> > this.. According my knowldge a ActionForm is always populated before the
> > perform method is called on the Action class..
> >
> > can anyone please enlighten this situation
> >
>
> It will be null if and only if you have not associated an input form with
> this action.  Otherwise, an ActionForm will have been created and
> populated
> if it didn't already exist.
>
> Now, of course, since I wrote the entire app in this case, I
> *know* that the
> configuration file is correct, and the null checks are not strictly
> necessary.  On the other hand, if I was writing actions and
> someone else was
> building struts-config.xml, I'd generally do a little defensive
> coding like
> this to protect myself from configuration file mistakes ...
>
> >
> > Thanks for ur time
> > Anand
>
> Craig
>
>
>


Mime
View raw message