Alberto A. Flores wrote:
Does anyone knows why the API for the StrutsTypeConverter abstract class
takes an array of Strings instead of a single one (the convertFromString
method)? The sample app seems to be always checking for the first
element. Is OGNL supposed to add more? Any feedback will be appreciated...
Because the data passed in to the Servlet (via get or post) is an array
of strings. The type converters are simply using the passed-in data.
This doesn't make immediate sense since most forms have uniquely named
form fields.
But that's not a requirement. It's valid to do this:
<input type="text" name="textfield" />
<input type="text" name="textfield" />
<input type="text" name="textfield" />
When the user enters data into those three fields and "posts" the
servlet has to handle an *array* of submitted values (since three values
will be posted, all associated with that single fieldname).
This "multiple values per name" situation is uncommon with text fields
(but possible, as noted above) but fairly common with radio buttons and
select lists with the "multiple" attribute enabled.
In short: because the servlet must always handle the *possibility* that
more than one value exists for any given key, its datatype for
representing those values is an array. And the converters are
converting from that servlet datatype into whatever the target datatype is.
- Gary
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]