RE: tag library problem with attributes

2000-10-12 Thread Magnus Rydin
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
   nameiterator/name
   tagclasscom.mongoosetech.tags.IteratorTag/tagclass
  
 teiclasscom.mongoosetech.tags.IteratorTagInfo/teiclass
   bodycontentJSP/bodycontent
   attribute
namename/name
requiredtrue/required
   /attribute
   attribute
nametype/name
requiredfalse/required
   /attribute
   attribute
namecollection/name
requiredtrue/required
rtexprvaluetrue/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-uritags/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
 
 





RE: tag library problem with attributes

2000-10-12 Thread Kit Cragin
Title: RE: tag library problem with attributes



Thanks! Amazing how you can stare at code for hours and 
then someone comes along and notices the problem 
immediately!

- 
Kit

  -Original Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]]On Behalf Of Magnus 
  RydinSent: Thursday, October 12, 2000 1:25 AMTo: 
  Orion-InterestSubject: RE: tag library problem with 
  attributes
  Kit, should that be %=library.getBooks()% (notice the equals sign missing in your 
  code)