We are using JSP quitte a lot, however we find one thing in the
specification with regard of parsing properties extremely annoying. The
official specification for the behaviour of parsing fields are:

-- start specification

2.13.2.1 Syntax

<jsp:setProperty name=" beanName" prop_expr />
prop_expr ::= property="*"

< some more stuff >

If you set propertyName to * then the tag will iterate over the
current ServletRequest parameters, matching parameter names
and value type(s) to property names and setter method type(s), setting
each matched property to the value of the matching parameter. If a
parameter has a value of ��, the corresponding property is not
modified.

-- end specification

At first I wondered why they thought it was handy to leave the property
uncahnged when the input is an empty string. After a while of cursing I
thought of the fact that the property could be of different types, like
String, boolean, etc. You can't define a universal rule for setting the
property to a default value after an empty field.

However most of the time I use String properties and I need to know
wheter somebody changed a field from its original value. With the
current specifications there is no way to do this. I have to write some
extra code that clears the properties of a bean after rendering a JSP
page, processing the JSP page will set only the properties with a value.
This is fine, however there is one big disadvantage, besides the extra
work and small performance penalty: the state of the (cleared) bean
doesn't reflect its actual state.

What I would like to see is that at least for the String properties the
semantics will change so an empty field will result in a null value or
an empty String passed to the property.

If somebody has a nicer solution please let me know
--
Mark Brouwer
Virgil B.V.

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
For JSP FAQ, http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to