yeah, i tried that too.  no difference...

thanks though,
chris

| chris wilson || web dev ||| [EMAIL PROTECTED] || | www.wondergeek.com |
|

> -----Original Message-----
> From: Martin Cooper [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 10, 2001 1:16 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Can I use a Map.Entry as a bean?
>
>
> Just a thought, but have you tried "java.util.Map$Entry" instead of
> "java.util.Map.Entry" when you specify the type?
>
> --
> Martin Cooper
> Tumbleweed Communications
>
> ----- Original Message -----
> From: "Chris Wilson" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, January 09, 2001 12:00 PM
> Subject: RE: Can I use a Map.Entry as a bean?
>
>
> > here's a simple example  of what i'm talking about.  would one of your
> > wizards please try this servlet and jsp page to see what i'm talking
> about?
> > thanks very much!
> >
> > i tried this on tomcat 3.2.1, jdk 1.3, win 2000
> >
> > ###### Begin TestServlet.java ######
> >
> > import javax.servlet.http.HttpServlet;
> > import javax.servlet.http.HttpServletRequest;
> > import javax.servlet.http.HttpServletResponse;
> > import javax.servlet.ServletException;
> > import java.util.HashMap;
> > import java.io.IOException;
> >
> > public class TestServlet extends HttpServlet {
> >    public void doGet(HttpServletRequest req, HttpServletResponse res)
> >    throws ServletException, IOException {
> >       HashMap map = new HashMap();
> >       map.put("test", "hope this works");
> >       map.put("foo", "bar");
> >       req.setAttribute("map", map);
> >       getServletContext().getRequestDispatcher("/display.jsp").forward(
> >          req, res);
> >    }
> > }
> >
> > ###### End TestServlet.java ######
> >
> > ###### Start display.jsp ######
> >
> > <%@ taglib uri="struts-logic.tld" prefix="logic" %>
> > <%@ taglib uri="struts-bean.tld" prefix="bean" %>
> > <html>
> > <head>
> > <title>display.jsp</title>
> > </head>
> >
> > <body>
> > <logic:iterate name="map" id="entry" scope="request"
> > type="java.util.Map.Entry">
> > <!-- i get an IllegalAccessException when running the following two
> > lines -->
> > <!-- delete the following two lines to elimate the
> > IllegalAccessException -->
> > <bean:write name="entry" property="key" scope="page" /> ->
> > <bean:write name="entry" property="value" scope="page" /><br>
> > <!-- why dosen't this work? -->
> > <!-- end delete -->
> >
> > <!-- these two lines work!  they don't throw an exception -->
> > <!-- they are functionally equivelent to the above two lines right? -->
> > <%= ((java.util.Map.Entry)pageContext.getAttribute("entry")).getKey()
> %> ->
> > <%= ((java.util.Map.Entry)pageContext.getAttribute("entry")).getValue()
> > %><br>
> > </logic:iterate>
> > </body>
> > </html>
> >
> > ###### End display.jsp ######
> >
> > | chris wilson || web dev ||| [EMAIL PROTECTED] || |
> www.wondergeek.com
> |
> > |
> >
> > > -----Original Message-----
> > > From: Chris Wilson [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, January 04, 2001 10:46 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: RE: Can I use a Map.Entry as a bean?
> > >
> > >
> > > yes,
> > >
> > > i've included both taglib defs...  in fact, the tags are
> working great.
> > > it's only the write tag that's having a problem, and only when i
> > > try to get
> > > a property on a Map.Entry
> > >
> > > <bean:write name="subjectEntry" property="value" scope="page"
> /> // this
> > > fails with an IllegalAccessException...
> > >
> > > ((java.util.Map.Entry)pageContext.getAttribute("subjectEntry)).get
> > > Value() //
> > > this works!
> > >
> > > if i use my own bean in the write tag, everything is dandy.  it's just
> the
> > > dang Map.Entry!
> > >
> > > | chris wilson || web dev ||| [EMAIL PROTECTED] || |
> > > www.wondergeek.com |
> > > |
> > >
> > > > -----Original Message-----
> > > > From: Ted Husted [mailto:[EMAIL PROTECTED]]
> > > > Sent: Thursday, January 04, 2001 10:11 AM
> > > > To: Struts List
> > > > Subject: Re: Can I use a Map.Entry as a bean?
> > > >
> > > >
> > > > So, you've included the Struts bean tag library along with
> logic, yes?
> > > >
> > > > <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> > > > <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
> > > >
> > > > You can get some weird and misleading error messages if you omit a
> > > > taglibs you're using.
> > > >
> > > > The inner class shouldn't cause a problem, since the iterate tag is
> > > > designed for that (an attribute or property of an attribute).
> > > >
> > > > For more troubleshooting, did you try setting the inner class as a
> > > > standalone page attribute, to see if that works too?
> > > >
> > > > *********** REPLY SEPARATOR  ***********
> > > >
> > > > On 1/4/2001 at 9:17 AM Chris Wilson wrote:
> > > >
> > > > hello,
> > > >
> > > > sorry to post this similar message again, but i'm really stumped...
> > > >
> > > > i've run into a problem however trying to use the iterate tag with a
> > > > TreeMap
> > > > and the write tag...  here's a snippet of my code:
> > > >
> > > > <logic:iterate name="subjects" id="subjectEntry" scope="request"
> > > > type="java.util.Map.Entry">
> > > > // subjects is a TreeMap in the request object... no problem there
> > > > // it's my understanding that when the iterate tag is used
> with a map,
> > > > the
> > > > // iterator is on the Set of Map.Entries returned by
> Map.entitySet(),
> > > > // therefore the object exposed as subjectEntry should be a
> > > > java.util.Map.Entry
> > > >
> > > > <bean:write name="subjectEntry" property="value" scope="page" />
> > > > // this is where i get an IllegalAccessException attempting
> to access
> > > > the
> > > > //property value of subjectEntry, even though there is a getValue()
> > > > method
> > > > in the
> > > > //api...
> > > >
> > > > </logic:iterate>
> > > >
> > > > just for fun, i replaced the write tag above with the following
> > > > scriptlet
> > > > which i believe is logically equivalent:
> > > > <%=
> > > >
> ((java.util.Map.Entry)pageContext.getAttribute("subjectEntry)).getValue(
> > > > )
> > > > %>
> > > >
> > > > and that works!  of course, i could simply use this scriptlet and my
> > > > problem
> > > > would be solved, but i'd like to use only taglibs if possible and it
> > > > seems
> > > > to me that the <bean:write> tag should do the same thing...
> > > >
> > > > will <bean:write> only work on "bean-like" objects that are public?
> in
> > > > this
> > > > case the object implementing the Map.Entry interface is an
> inner class
> > > > in
> > > > TreeMap.  is that causing the problem?
> > > >
> > > > what am i missing?  thanks for any help!
> > > >
> > > > cheerio,
> > > > chris
> > > >
> > > > | chris wilson || web dev ||| [EMAIL PROTECTED] || |
> > > > www.wondergeek.com |
> > > > |
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
>
>
>

Reply via email to