struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim B" <timblanch...@shaw.ca>
Subject Re: Struts1 forms with empty Strings
Date Sun, 02 Mar 2008 02:44:09 GMT

"Dave Newton" <newton.dave@yahoo.com> wrote in message
news:362194.56664.qm@web56705.mail.re3.yahoo.com...
> --- Andy <andrhahn@hotmail.com> wrote:
> > I was wondering if there is a way to configure Struts1 so Form beans
return
> > null values instead of empty String values when a user does not enter
data
> > in a text field, for example.  The problem is that Hibernate then saves
> > empty Strings to the database instead of nulls.  I would like to
configure
> > something globally if possible.
>
> I don't know if this is possible without writing some code, like a request
> processor; hopefully somebody else knows more. The issue is that a text
field
> on a form returns an empty string, not null: that's an HTTP thing, not
Struts
> specifically.
>
> You could also configure Hibernate data types that convert an empty string
in
> to null and handle the problem on the Hibernate side; if you're using the
> Hibernate code anywhere else it might be more useful to do it that way,
but
> it's borderline magic and might be confusing down the road.
>
> Dave

A filter that intercepts the request and removes all parameters with empty
values should do the trick. I have used a similar filter to trim all the
reqest parameters of white space rather than doing it in the form bean
setter methods.




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message