Sandra Reichert wrote:
Hi,
I have an input form in jsp. After submitting empty fields (user entered
nothing in input field) are set by default with specific values
depending on their data typ.
So an empty Integer field is set to 0, an String field to "" an so on.
But i want to have a null value for empty fields.
Or in other words: How can i decide if for example the 0 is entered by
user or the default initialization.
This is one of the many reasons you should prefer String-valued form
bean properties, rather than using int/Integer, etc. That way, you can
redisplay incorrect/invalid inputs for the user to edit and correct.
What if the user types 'two' into a field that's backed by an
Integer-typed property? Resetting it to 0 is clearly not what you want,
but resetting it to null isn't great either.
If you don't care about redisplaying input values and/or you really
can't change your form properties to be String-typed, the best you can
do it to re-configure the BeanUtils converters to use null as a default
instead of 0.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]