I'm not sure if this is the right venue for suggestions, but
here goes...
Suppose you have a form with fields that are intended to set
the properties of an object (a bean, or a Torque om object).
It's handy to be able to use parameters.setProperties(theobject)
in your action code (where parameters is a ParameterParser,
a sub-interface of ValueParser). This sets theobject's
properties using any parameters whose names match those of
properties.
Suppose instead that you have a form with 2 sets of fields
that are used to set the properties of two instances of the
same class of object. For example, you might have billing
address and shipping address fields, both of which will be
used to set the properties of instances of class Address.
ValueParser.setProperties can't be used in this case.
I propose adding a variant of setProperties that takes two
parameters, the object whose properties should be set, and a
prefix string to use when looking for property names. Then
you could have in your action the following code:
parameters.setProperties(billingAddress, "billing_");
parameters.setProperties(shippingAddress, "shipping_");
and in the form you'd have fields with names like
"billing_street", "billing_state", "shipping_street",
"shipping_state", etc.
I've written a silly little wrapper class that takes a
ValueParser in its constructor, and has a method:
public void setProperties(Object bean, String prefix)
throws Exception
which it implements by using the underlying ValueParser's
add() and remove() methods to modify the ValueParser's
hashtable, then calls ValueParser.setProperties(Object),
and then uses add() and remove() to put the ValueParser
back the way it was. I think it would be useful to put
this functionality directly in the ValueParser interface.
Any comments? Does anyone else think that this would be
useful to them?
Jeremy Leader
[EMAIL PROTECTED]
626-794-2145
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]