I don't understand either why it was done like that. Even if the parameter
is empty it should try to set the property to which .valueOf(String) is
successful. So properties accepting a B/boolean or String(of course) or
C/char should be set by the jsp:setProperty action. "Setter" method
accepting an int would be left unchanged.

Can somebody clears out why it hasn't been done like that. I don't see why
empty parameters can't be used to set an object property.

Pascal
-----Original Message-----
From: Mark Brouwer [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 18, 1999 4:29 PM
To: [EMAIL PROTECTED]
Subject: Annoying thing in the Java specifications


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

===========================================================================
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