Johnny Blaze wrote:
>
> Hi All,
>
> I'm trying to a pass a bean to my custom tag. Is this possible? as you can
> see from my code below, I've enclosed <%=mybean%> in quotes. The browser
> then complains that I cannot convert the string to an IteratorBean. If I
> removed the quotes the brower complains that I need the quotes.
>
> Then first part of the code sample is code from my JSP page. The second
> part is my part of my tag definition which assigns IteratorBean to the bean
> passed through the tag.
>
> **** START OF CODE ******
> <!-- in my .jsp page -->
> <jsp:useBean id="myBean" class="IteratorBean" />
> <test:repeat bean="<%=mybean%>"></test:repeat>
>
> // in my tag definition
> IteratorBean bean = null;
>
> public void setBean(IteratorBean bean){
> this.bean = bean;
> }
>
> **** END OF CODE ********
>
> thanks in advance,
You must mark the tag attribute as accepting request-time attribute values
in the TLD:
<attribute>
<name>bean</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
Then you can use the "<%= mybean %>" syntax to assign the attribute
a reference to the bean.
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.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