This may help.

 

In your tag use

pageContext.setAttribute("date", new Date());

pageContext.setAttribute("color", color);

pageContext.setAttribute("font", font); and so on

 

in the jsp page

<taglib1:dateTag color="red" font="Arial" fontSize="+1" >

<font style=\"font-family:<%=font%>; font-size:<%=fontSize%>; color:<%=color%>"\><%=date%></font>

</taglib1:dateTag>

/Nils

>From: Anders Lindell <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: Problems - setting attributes in taglib directives
>Date: Fri, 23 Feb 2001 12:10:29 +0100
>
>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(""+date+"");
> }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)
>--------------
>
>
>
>
> 1.0
> 1.1
> taglib1
> some simple tags
>
>
> dateTag
> tagLib1.HelloTag
> empty
> a hellotag
>
>
> color
> true
>
>
> font
> true
>
>
> fontSize
> true
> true
>
>
>
>
>--------------
>I put this in web.xml
>--------------
>
> TagLib1
> /WEB-INF/tagLib1.tld
>
>--------------
>This is my jsp using the tag
>--------------
><%@ taglib prefix="tag1" uri="TagLib1" %>
>
>
>
>
>
>
>
>
><% String str = "10px"; %>
>
>
>
>
>
>--------------
>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 ..
> > > 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 ... in the taglib directives file. My tld-file looks like this;
> > > -------------
> > >
> > >
> > >
> > >
> > >
> > > 1.0
> > > 1.1
> > > taglib1
> > > some simple tags
> > >
> > >
> > > getFieldInRow
> > > tagLib1.GetFieldInRow
> > > empty
> > >
> > >
> > > preText
> > > false
> > > false
> > >
> > >
> > > postText
> > > false
> > > false
> > >
> > >
> > > row
> > > true
> > > true
> > >
> > >
> > > col
> > > true
> > > false
> > >
> > >
> > >
> > >
> > > -------------
> > > 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...
> > > --------------
> > > ----
> > >
> > >
> > >
> > > --
> > >
> > > 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


Get your FREE download of MSN Explorer at http://explorer.msn.com

=========================================================================== 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

Reply via email to