I believe the base requirement for Struts 1.1 is JDK 1.2 or later. Since
LinkedHashMap was introduced in JDK 1.4, it really can't be used in the Struts
codebase. I suppose org.apache.commons.collections.SequencedHashMap could be
used in its place. However, the problem is really more general than that. What
if someone was using a SortedMap? Or a WeakHashMap? Or SomeOtherSpecialMap? The
process of doing:

results = new HashMap(map);

blows away any special functionality that might impact how the original map
makes entries available. I'm not exactly sure why the entries are copied out of
the original map, but it may have something to do with trying to avoid raising
a ConcurrentModificationException.

Quoting Ron Grabowski <[EMAIL PROTECTED]>:

> > From: "James Mitchell" <[EMAIL PROTECTED]>
> > To: "Struts Users Mailing List"
> > <[EMAIL PROTECTED]>
> > Subject: Re: html:link and map of request parameters
> > Date: Mon, 7 Jun 2004 12:23:33 -0400
> > 
> > Here's how I do it:
> > (This demonstrates both static and dynamic values
> > for use with the
> > html:link)
> > 
> > 
> > ...
> > ...
> > <jsp:useBean id="myLinkParams"
> > class="java.util.HashMap"/>
> > <c:set target="${myLinkParams}" property="id"
> > value="${dto.id}"/>
> > <c:set target="${myLinkParams}" property="type"
> > value="edit"/>
> > 
> > ...later down the page...
> > 
> >      <html:link action="/manageUserAccount"
> > name="myLinkParams">
> >          <bean:message key="edit.user.link.text"/>
> >      </html:link>
> 
> http://jakarta.apache.org/struts/userGuide/struts-html.html#link
> 
> "
> Specify only the name attribute - The named JSP bean
> (optionally scoped by the value of the scope
> attribute) must identify a java.util.Map containing
> the parameters
> "
> 
> I looked at jakarta-struts-1.1-src's
> RequestUtils.computeParameters and saw that it uses a
> HashMap:
> 
> // Create a Map to contain our results from the
> multi-value parameters
> Map results = null;
> if (map != null) {
>       results = new HashMap(map);
> } else {
>       results = new HashMap();
> }
> 
> I wish I was able to use a LinkedHaspMap in my
> useBean:
> 
> <jsp:useBean id="myLinkParams"
> class="java.util.LinkedHaspMap"/>
> 
> so the items I add to the Map appear in the same order
> in the rendered HTML.
> 
> Is there anyway to have Struts adhere to the Map 
> interface instead of forcing the object into a
> HashMap?
> 
> - Ron

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

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

Reply via email to