Hi all,

I recently ran in to a need to perform a task that's been discussed on
this list at least a couple of times since I've subscribed.
Unfortunately, an actual way to make it work was only described once,
and that approach was unappealing.

The problem is that I would like to construct a JSP with an HTML FORM
that has a series of similar lines, using logic:iterate. The fundamental
problem is that the various struts-form tags use the same name for all
instances of a control in a given "column". This means that struts can't
automatically shove the posted data back into the form bean for you (at
least correctly!).

The one approach to solving this that I saw (over the last two months
or so) was by Chandan Kulkarni. If you want to go back and check it
out, here are the headers:

Date: Fri, 5 Jan 2001 07:44:11 -0500
To: <[EMAIL PROTECTED]>, "Mishkin Berteig" <[EMAIL PROTECTED]>
From: "Chandan Kulkarni" <[EMAIL PROTECTED]>
Cc: "Chandan Kulkarni" <[EMAIL PROTECTED]>
Subject: Re: Help: <logic:iterate> and form input fields
Message-ID: <002f01c07715$3520bb50$[EMAIL PROTECTED]>

This approach involves:

(a) using raw HTML form tags, e.g., <input> instead of <form:text>.

(b) constructing the value of the "name" and "value" attributes for the
    HTML form tags using JSP expression substitution - <%= %>.

(c) Changing public static void populate(Object, String, String,
    HttpServletRequest) in BeanUtils.java to comment out the code which
    discards any subscript expression that might be present in the name
    part of a posted name/value pair.

(d) Inserting code into public static void populate(Object, HashTable)
    in BeanUtils.java to look for an indexed or nested reference in the
    property name, and using PropertyUtils.setProperty to handle the
    setting in this case.

Is there no way to accomplish this without all this monkey motion? I
would very much like to find a solution that doesn't require me to
modify code in struts.jar, and keep those changes up to date in the face
of future changes to struts. The fact that the code modified in (c)
*has* a check for a subscripted reference indicates to me that *someone*
was thinking along these lines in the past. Was the original intent to
do this in a different way? What am I breaking by commenting out this
code now?

Better yet, does anyone have a *better* alternative? I'm not at all
averse to writing some tags to hide complexity at that point, or using a
derived ActionServlet class (I already am in fact, to load some
initialization parameters), but I'd really like to avoid modifying
struts itself!

Am I being unreasonable? Are there really so few people out there that
want such an ability that no one has worked out a better way to do this?

-- Erik


Reply via email to