On 22 Jul 2002, David M. Karr wrote:

> Date: 22 Jul 2002 20:07:22 -0700
> From: David M. Karr <[EMAIL PROTECTED]>
> Reply-To: Struts Developers List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Struts-EL: Ideas about "name" and indexed "name" attributes?
>
> In mapping Struts tags to Struts-EL, I'm wondering about the "name" attribute
> of the generated HTML for these tags, along with the "property" attribute of
> the custom tag, and "indexed" tags.
>
> In the current Struts library, in the "checkbox" tag, for instance, the
> strategy of setting the "name" and "property" attributes nicely flows the
> specified field values back into the specified actionform and property on the
> return trip.  If the "indexed" attribute is set, it nicely builds an index
> reference, which will eventually cause the correct array/collection entry to be
> set.
>
> I'm thinking and thinking about how I can possibly map something like this to
> JSTL functionality, and I just don't see it.  I was assuming that the
> "name/property" functionality would be mutually exclusive with the JSTL
> functionality, but in at least the HTML tags, where the "name/property" pair is
> used to build the HTML "name" attribute, I don't see how I can replace that.
>
> In the case of "checkbox", the "value" attribute and others could still use the
> EL engine, just not the "name/property" functionality.
>
> Does anyone have any ideas about this?
>

I've been thinking about this issue as well, as you might imagine.

For general form field properties, I'm assuming that we would have to make
the existence of the form bean explict -- say, for example:

  <html-el:test var="${logonForm.username}"/>

instead of assuming that you could just use username and "know" that it
was resolved against the form bean in the surrounding scope.  The property
name can either be inferred from the expression (i.e. after the first
period), or we could allow an optional "property" attribute that would
provide the field name for the rendered <input> field.

For indexed things, remember that the subscript in an EL expression can be
a variable.  So something like this should work, where "customers" is an
array of customer objects, and we're inside a form with a field per
customer account number:

  <c:forEach var="customer" items="customers" varStatus="status">
    <html-el:text var="${customer.id}"
             property="customers[${status.index}]"/>
  </c:forEach>

could do the trick, as long as you scanned both the "var" and "property"
attributes for expressions.

> David M. Karr          ; Java/J2EE/XML/Unix/C++

Craig


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to