The problem lies in the fact that you've overloaded the setter method
for accessList. According to the JavaBeans spec, you can't do that;
only one setter per property name is supported. So, first of all,
you'll need to give the attributes two different names and make them
both optional.
For example:
public void setAccessList(Collection accessList) {
this.accessList = accessList;
}
public void setAccessListName(String accessListName) {...}
But what's more, because of the way tag pooling works, you probably
don't want to resolve the name in the setter method as you do below (see
http://jakarta.apache.org/taglibs/guidelines.html) so you should have an
accessListName field too, and write setAccessListName just like:
public void setAccessListName(String accessListName) {
this.accessListName = accessListName;
}
then, in doStartTag:
Collection accessList = this.accessList;
if (accessList == null) {
accessList = (Collection) pageContext.findAttribute(accessListName);
}
Kind of a pain, but that's the only way to be fully compliant with the
spec.
--
Tim Moore / Blackboard Inc. / Software Engineer
1899 L Street, NW / 5th Floor / Washington, DC 20036
Phone 202-463-4860 ext. 258 / Fax 202-463-4863
> -----Original Message-----
> From: Cindy Ballreich [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, October 15, 2002 1:13 PM
> To: [EMAIL PROTECTED]
> Subject: Custom Tag / JavaBean question
>
>
>
> I have a custom tag that takes a collection as one of it's
> parameters. I'd like to be able to give the name of an
> attribute (a String) as the value and have the tag find the
> attribute from the pageContext. This doesn't seem like it
> should be too difficult. I have setters that look like this
> in my tag...
>
> protected Collection accessList;
>
> public void setAccessList(String accessList) {
> Object o = pageContext.findAttribute(accessList);
> if (o instanceof Collection) {
> this.accessList = (Collection)o;
> }
> }
>
> public void setAccessList(Collection accessList) {
> this.accessList = accessList;
> }
>
> ...and the tag looks like this on the jsp page...
>
> <jsp:useBean id="accessList" scope="request"
> class="java.util.Vector" />
> <mpi:accessList id="access" accessList="accessList" ... >
> ...
> </mpi:accessList>
>
> ... but I keep getting errors like this...
>
> org.apache.jasper.JasperException: Unable to convert string
> 'accessList' to class java.util.Collection for attribute
> accessList: java.lang.IllegalArgumentException: Property
> Editor not registered with the PropertyEditorManager
> at
> org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromProper
> tyEditorManager(JspRuntimeLibrary.java:749)
>
> If I use a run time value in the tag I don't get the error...
>
> <jsp:useBean id="accessList" scope="request"
> class="java.util.Vector" />
> <mpi:accessList id="access" accessList='<%= accessList %> ... >
> ...
> </mpi:accessList>
>
> So I have a workaround for the problem, but I'd still like to
> understand why the first example doesn't work when everything
> I've read says that it should.
>
> I'm using Tomcat 4.1.12 on NT 4.0 (development server) with
> j2sdk1.4.0_01.
>
> Thanks
>
> Cindy
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:tomcat-user-> [EMAIL PROTECTED]>
> For
> additional commands,
> e-mail: <mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>