Hello Hans,
Thank you for your answer. I should have asked my question more
specific:
I want to write a custom tag what converts a date into a well formatted
germanlike string. So I want to take the bean declared by useBean (which
can be of any type), call a method on this bean which gives a date back
and convert this date:
<jsp:useBean id="testBean" class="concept.TestBean" scope="request"/>
<mylib:date ref="testBean" getProperty="date" />
For now I call the appropriate method on testBean with reflection:
public int doStartTag() throws JspException {
Object o = pageContext.findAttribute(beanName);
try {
Class objectClass = o.getClass();
Method aMethod = objectClass.getDeclaredMethod(
convertPropertyNameToGetMethodName(propertyName), null); //
use of a
private method
Date date = (Date)aMethod.invoke(o, null);
pageContext.getOut().print(date); // date formatting not yet included
} catch (Exception e) {
e.printStackTrace();
}
return SKIP_BODY;
}
But I am wondering if there is a better way to do this, because in the
JSP spec on page 109 (5.6.1 Ids and PageContext) is something written
about id and ref attribute but with no example. And, at second point,
there is the TagExtraInfo class which stores type information about
scripting variables.
I think there is a way to get the TagExtraInfo of the useBean-Tag to get
the right type or there is any magic about the id and ref attribute. Do
you know something about that?
Adolf
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
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