Title: RE: tag library problem with attributes

Kit, should that be
<%=library.getBooks()%> (notice the equals sign missing in your code)
WR

> -----Original Message-----
> From: Kit Cragin [mailto:[EMAIL PROTECTED]]
> Sent: den 12 oktober 2000 07:52
> To: Orion-Interest
> Subject: tag library problem with attributes
>
>
> Hi:
>
> I am getting the error message "Attribute of type
> 'java.util.Collection'
> must be a request time attribute" when Orion attempts to
> parse my JSP. This
> seems weird because I do set <rtexprvalue> to true in my
> taglib.tld (see
> below). I was attempting to create an iterator similar to the
> one defined in
> the orion taglib tutorial at
> http://www.orionserver.com/taglibtut/index.jsp
> and include it in my web application.
>
> My JSP contains:
>
> <%@ taglib uri="tags" prefix="model" %>
> <jsp:useBean id="library" type="com.mongoosetech.model.Library"
> scope="application"/>
> ...
> <model:iterator name="book" type="com.mongoosetech.model.Book"
> collection="<% library.getBooks() %>">
>       <jsp:getProperty name="book" property="name"/><br/>
> </model:iterator>
>
> where library.getBooks() returns a java.util.Collection of
> Book. I have 2
> classes:
>
> public class NestedTagInfo extends TagExtraInfo
> {
>       public VariableInfo[] getVariableInfo(TagData data)
>       {
>               return new VariableInfo[]
>               {
>                       new
> VariableInfo(data.getAttributeString("name"),
> data.getAttributeString("type"), true, VariableInfo.NESTED)
>         };
>     }
> }
>
> and
>
> public class IteratorTag extends BodyTagSupport
> {
>       public int doStartTag()
>       {
>               if (iterator == null || !iterator.hasNext())
> return SKIP_BODY;
>               pageContext.setAttribute(name, iterator.next(),
> PageContext.PAGE_SCOPE);
>               return EVAL_BODY_TAG;
>       }
>
>       public int doAfterBody() throws JspException
>       {
>               if( !iterator.hasNext()) return SKIP_BODY;
>               pageContext.setAttribute(name, iterator.next(),
> PageContext.PAGE_SCOPE);
>               return EVAL_BODY_TAG;
>       }
>       public int doEndTag() throws JspException
>       {
>         try
>         {
>               if(bodyContent != null)
>                      
> bodyContent.writeOut(bodyContent.getEnclosingWriter());
>         }
>         catch(java.io.IOException e)
>         {
>               throw new JspException(e.getMessage());
>         }
>               return EVAL_PAGE;
>       }
>       public void setName(String name)
>       {
>               this.name = name;
>       }
>       public void setCollection(Collection collection)
>       {
>               if (collection.size() > 0) iterator =
> collection.iterator();
>       }
>       public void setType(String type)
>       {
>               this.type = type;
>       }
>       private String name;
>       private String type;
>       private Iterator iterator;
> }
>
> defined in the com.mongoosetech.tags package and a taglib.tld
> that looks
> like:
>
> <taglib>
>       ...
>       <tag>
>               <name>iterator</name>
>               <tagclass>com.mongoosetech.tags.IteratorTag</tagclass>
>              
> <teiclass>com.mongoosetech.tags.IteratorTagInfo</teiclass>
>               <bodycontent>JSP</bodycontent>
>               <attribute>
>                       <name>name</name>
>                       <required>true</required>
>               </attribute>
>               <attribute>
>                       <name>type</name>
>                       <required>false</required>
>               </attribute>
>               <attribute>
>                       <name>collection</name>
>                       <required>true</required>
>                       <rtexprvalue>true</rtexprvalue>
>               </attribute>
>       </tag>
> </taglib>
>
> and is a part of WEB-INF/lib/tags.jar which has the structure:
>
> com/mongoosetech/tags/IteratorTag.class
> com/mongoosetech/tags/IteratorTagInfo.class
> META-INF/taglib.tld
>
> Finally, I have a web.xml with an entry to point to the tag library:
>
> <taglib>
>       <taglib-uri>tags</taglib-uri>
>       <taglib-location>/WEB-INF/lib/tags.jar</taglib-location>
> </taglib>
>
>
> Anyone have any ideas why this is happening? Thanks...
>
> Kit Cragin
> VP of Product Development
> Mongoose Technology, Inc.
> www.mongoosetech.com
>
>

Reply via email to