Hi,
I found a workaround.
If in the doStartTag method I change

pageContext.setAttribute(name, iterator.next(), PageContext.PAGE_SCOPE);

to

pageContext.setAttribute(name, iterator.next());

Then the tag works on 0.96.

I checked it out and if I use PageContext.PAGE_SCOPE in the taglib I can retrieve
it from application scope. So I think this is defined wrong and is a bug.

Is [EMAIL PROTECTED] where bugs should be sent? Couldn't see anything on Web Site.

Hope this helps,
Eric :-)
 

Eric Richardson wrote:

Hi Brian,
Brian Cunningham wrote:
Hi Eric,Is it "product" vs "products"?

products is the collection, product is one of the elements of the collection
Product product = (Product) products.get(0);

Then hash as product1. This is called in doStartTag and in doAfterBody as

pageContext.setAttribute(name, iterator.next(), PageContext.PAGE_SCOPE);
Bu there must be a problem in the Tag because if I put an object in the pageContext as below the iterate works and prints out the same object 16 times.(since there are sixteen items in the products Collection. So the Tag partly works. I'm reading the spec and I will probably put debug messages in the tag. The only thing I see so far is that the doInitBody method has been omitted. Don't know if something should be in that tag.
 

<% pageContext.setAttribute("product1", product); <-----------------
 
 

<ts:iterate name="product1" collection="<%= products %>"> <----------------

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Eric Richardson
Sent: Tuesday, April 18, 2000 10:12 AM
To: Orion-Interest
Subject: Tag Example Problem
 

Hi,
I searched the archives and couldn't find anything relevent.

I'm trying to use the Iterate.java tag in some code I have. I pass the collection but the nested usebean tag cannot find the object in page scope.

500 Internal Server Error

java.lang.InstantiationException: Could not find the bean named 'product1' in the page scope
        at /product_demo.jsp._jspService(/product_demo.jsp.java:171)
        at com.evermind.server.http.EvermindHttpJspPage.service(JAX)
        at com.evermind.server.http.HttpApplication.r4(JAX)
        at com.evermind.server.http.JSPServlet.service(JAX)
        at com.evermind.server.http.c9.oh(JAX)
        at com.evermind.server.http.c9.forward(JAX)
        at com.evermind.server.http.dg.b8(JAX)
        at com.evermind.util.e.run(JAX)

If I put an object in scope of the correct type it iterates through the list and prints everything out so I know the collection is fine.
<% pageContext.setAttribute("product1", product);

<ts:iterate name="product1" collection="<%= products %>">

  <jsp:useBean id="product1" scope="page" type="com.ratex.db.Product"/>
  <!--  Product: <%=product1 %> -->
  <tr>
    <td>
      <jsp:getProperty name="product1" property="productId"/>
    </td>
    <td> <%=product1.getCategory() %> </td>
    <td> <%=product1.getName() %> </td>
    <td> <%=product1.getDescription() %> </td>
  </tr>
</ts:iterate>

I haven't quite figured out the code but it seems it should work correctly.  Seems like the
setAttribute(...) is not getting called.

  public int doStartTag() {
    if(iterator == null) { //Make sure we have a Iterator
      return SKIP_BODY;
    }
    if(iterator.hasNext()) { //check if we got more elements
      // add the Bean to the pageContext using the given name
      pageContext.setAttribute(name, iterator.next(), PageContext.PAGE_SCOPE);
      return EVAL_BODY_TAG;
    }
    else {
      return SKIP_BODY;
    }
  }

Any help would be appreciated.

Eric :-)

Reply via email to