struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <>
Subject Re: Fw: Struts1 forms with empty Strings
Date Sun, 02 Mar 2008 03:06:18 GMT
--- Martin Gainty <> wrote:
> Tim and Dave
> /what about creating your own WhateverFormBean and setting all attribs to
> null as default instead of empty string e.g.
> WhateverFormBean extends FormBeanConfig {
>     /**
>      * An example String property.
>      */
> //change
>     private String example = "";
> //to
>     private String example=null;
> ..
> };

AFAIK an empty form field will still send an empty string back from the
browser, and the default behavior would be to set the form property with that
empty string, not null.

Unless some sort of processing happens (via a filter, as mentioned, a request
processor that removes empty parameters, etc.) I don't believe initializing
an ActionForm property would make any difference, at least for inputs that
would send back an empty string when unfilled.

It would, of course, make a difference for checkboxes, which are not sent at
all if unchecked, thus not transferred to the ActionForm.

As mentioned before, "null" is the default value for a String member variable


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

View raw message