OK.
Here is my code. It's not from the original one because I solved that another way, so
that code is gone. But I made a "hello-world" example that does not work.....
By the way - I'm not sure if I understand you right when you asking if I can set the
value in <%...%> jsp-scriplets. Is that possible! How can I get a reference to the
"tag"-object in my scriptlets? Using the findAncestorWithClass(....) method just works
in nested tags i think. But if this is true where to script. Isn't the object just
alive between the start-tag and the end-tag. Maybe I'm on a bikeride and please let me
know If I'm wrong.
Anyway here is my example;
---------------
Here is the simple tag-class
---------------
package tagLib1;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.util.Date;
import java.io.IOException;
public class HelloTag extends TagSupport {
public int doStartTag() throws JspException {
try {
JspWriter out = pageContext.getOut();
String date = new Date().toString();
out.print("<font style=\"font-family:"+font+"; font-size:"+fontSize+";
color:"+color+"\">"+date+"</font>");
}catch(IOException ioe) { throw new JspException("IOException"+ioe.toString(); }
return SKIP_BODY;
}
public int doEndTag() throws JspException {
return EVAL_PAGE;
}
public void setColor(String color) {
this.color = color;
}
public void setFont(String font) {
this.font = font;
}
public void setFontSize(String size) {
this.fontSize = size;
}
private String color = null;
private String font = null;
private String fontSize = null;
}//end class HelloTag
--------------
tagLib1.tld looks like this (located in WEB-INF)
--------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>taglib1</shortname>
<info>some simple tags</info>
<tag>
<name>dateTag</name>
<tagclass>tagLib1.HelloTag</tagclass>
<bodycontent>empty</bodycontent>
<info>a hellotag</info>
<attribute>
<name>color</name>
<required>true</required>
</attribute>
<attribute>
<name>font</name>
<required>true</required>
</attribute>
<attribute>
<name>fontSize</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
--------------
I put this in web.xml
--------------
<taglib>
<taglib-uri>TagLib1</taglib-uri>
<taglib-location>/WEB-INF/tagLib1.tld</taglib-location>
</taglib>
--------------
This is my jsp using the tag
--------------
<%@ taglib prefix="tag1" uri="TagLib1" %>
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#800000" ALINK="#FF00FF"
BACKGROUND="?">
<% String str = "10px"; %>
<tag1:dateTag color="#555555" font="verdana" fontSize="<%=str%>" />
</BODY>
</HTML>
--------------
The Exception;
--------------
javax.servlet.ServletException: javax.servlet.jsp.tagext.TagAttributeInfo: method
(Ljava/lang/String;ZZLjava/lang/String;)V not found
java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo: method
(Ljava/lang/String;ZZLjava/lang/String;)V not found
at
allaire.jrun.jsp.JRunTagLibraryInfo.buildAttributeInfo(JRunTagLibraryInfo.java:234)
at allaire.jrun.jsp.JRunTagLibraryInfo.buildTagInfo(Compiled Code)
at allaire.jrun.jsp.JRunTagLibraryInfo.initialize(Compiled Code)
at allaire.jrun.jsp.JRunTagLibraryInfo.(JRunTagLibraryInfo.java:61)
at allaire.jrun.jsp.JSPParser.directive(JSPParser.java:774)
at allaire.jrun.jsp.JSPParser.parse(Compiled Code)
at allaire.jrun.jsp.JSPParser.writeXML(JSPParser.java:151)
at allaire.jrun.jsp.JSPParser.generateXML(JSPParser.java:123)
at allaire.jrun.jsp.JSPParser.generateXML(JSPParser.java:67)
at allaire.jrun.jsp.JSPServlet.parsePage(JSPServlet.java:409)
at allaire.jrun.jsp.JSPServlet.createServlet(JSPServlet.java:381)
at allaire.jrun.jsp.JSPServlet.loadPage(Compiled Code)
at allaire.jrun.jsp.JSPServlet.service(Compiled Code)
at allaire.jrun.servlet.JRunSE.service(Compiled Code)
at allaire.jrun.servlet.JRunSE.runServlet(Compiled Code)
at allaire.jrun.servlet.JRunRequestDispatcher.forward(Compiled Code)
at allaire.jrun.servlet.JRunSE.service(Compiled Code)
at allaire.jrun.servlet.JvmContext.dispatch(Compiled Code)
at allaire.jrun.http.WebEndpoint.run(Compiled Code)
at allaire.jrun.ThreadPool.run(Compiled Code)
at allaire.jrun.WorkerThread.run(Compiled Code)
-------------
Peter - Thanks for trying to solve my probs
Kr
Anders
----- Original Message -----
From: "Peter Pilgrim" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 23, 2001 10:52 AM
Subject: Re: Problems - setting attributes in taglib directives
> Could you post your Tag java class and the JSP?
>
> Presumably setting the `row' parameter inside normal JSP script
> <% ... %> works, right?
>
> --
> Peter Pilgrim
> G.O.A.T
> "the Greatest Of All Time"
>
>
>
> ---------------------------------------- Message History
>----------------------------------------
>
>
> From: Anders Lindell <[EMAIL PROTECTED]>@java.sun.com> on 22/02/2001 21:15 CET
>
> Please respond to A mailing list about Java Server Pages specification and
> reference <[EMAIL PROTECTED]>
>
> DELEGATED - Sent by: A mailing list about Java Server Pages specification and
> [EMAIL PROTECTED]>
>
>
> To: [EMAIL PROTECTED]
> cc:
> Subject: Re: Problems - setting attributes in taglib directives
>
>
> Well, the taglib-examples that comes with JRun implements this functionality and the
>taglib XML looks like mine. Also, the Jsp engine complains and "says" to me to set
>the request time....attribute. So I'm just confused ...........
>
> KR
>
> Anders
>
> ----- Original Message -----
> From: "Peter Pilgrim" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, February 22, 2001 6:24 PM
> Subject: Re: Problems - setting attributes in taglib directives
>
>
> > Well it look perfectly fine to me.
> >
> > The taglib XML looks correct
> >
> > The setter method looks correct . (There is no obvious spellcheck bug !)
> >
> > Maybe the JSP Engine does not implement <rtexprvalue>..</rtexprvalue>
> > correctly. I think that TOMCAT 3.2.1 can't handle this. So I gave up
> > with REQUEST_TIME_VALUE attributes and used good all <% ... %>
> > to do the setting.
> >
> > Check your JSP Container documentation
> > --
> > Peter Pilgrim
> > G.O.A.T
> > "the Greatest Of All Time"
> >
> >
> >
> > ---------------------------------------- Message History
>----------------------------------------
> >
> >
> > From: Anders Lindell <[EMAIL PROTECTED]>@java.sun.com> on 22/02/2001 17:06 CET
> >
> > Please respond to A mailing list about Java Server Pages specification and
> reference <[EMAIL PROTECTED]>
> >
> > DELEGATED - Sent by: A mailing list about Java Server Pages specification and
> [EMAIL PROTECTED]>
> >
> >
> > To: [EMAIL PROTECTED]
> > cc:
> > Subject: Problems - setting attributes in taglib directives
> >
> >
> > Hi!
> >
> > I'm facing a problem when setting <attribute>...</attribute> in the taglib
>directives file. My tld-file looks like this;
> > -------------
> > <?xml version="1.0" encoding="ISO-8859-1" ?>
> > <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
>"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
> >
> > <taglib>
> >
> > <tlibversion>1.0</tlibversion>
> > <jspversion>1.1</jspversion>
> > <shortname>taglib1</shortname>
> > <info>some simple tags</info>
> >
> > <tag>
> > <name>getFieldInRow</name>
> > <tagclass>tagLib1.GetFieldInRow</tagclass>
> > <bodycontent>empty</bodycontent>
> >
> > <attribute>
> > <name>preText</name>
> > <required>false</required>
> > <rtexprvalue>false</rtexprvalue>
> > </attribute>
> > <attribute>
> > <name>postText</name>
> > <required>false</required>
> > <rtexprvalue>false</rtexprvalue>
> > </attribute>
> > <attribute>
> > <name>row</name>
> > <required>true</required>
> > <rtexprvalue>true</rtexprvalue>
> > </attribute>
> > <attribute>
> > <name>col</name>
> > <required>true</required>
> > <rtexprvalue>false</rtexprvalue>
> > </attribute>
> > </tag>
> >
> > </taglib>
> > -------------
> > In my "tag-class" it looks like this;
> > -------------
> > private String preText = "";
> >
> > public void setPreText(String str) {
> > preText = str;
> > }
> >
> > and so on with the other setters...
> > --------------
> > --<CUT>--
> >
> >
> >
> > --
> >
> > This e-mail may contain confidential and/or privileged information. If you are not
>the intended recipient (or have received this e-mail in error) please notify the
>sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or
>distribution of the material in this e-mail is strictly forbidden.
> >
> > ===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>
>
> --
>
> This e-mail may contain confidential and/or privileged information. If you are not
>the intended recipient (or have received this e-mail in error) please notify the
>sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or
>distribution of the material in this e-mail is strictly forbidden.
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets