Robert Nelson wrote:
>
> I am having the same problem that Christian noted back in May. I would
> like to be able to access JavaBean properties from within a custom tag.
> I do have the rtexprvalue flag set to true in the tld file. I'm getting
> the same error (missing ")"). I've looked at the spec and don't see
> why I should not be allowed to do this. Has anyone been successful
> in accessing JavaBean properties from within a custom tag using the
> <jsp:getProperty.../> format, or will I need to be satisified with
> using a JSP scriplet?
>
> examples of what does and doesn't work for me:
>
> WORKS:
> <ms:test name='((Customer)session.getAttribute("cust")).getName()'>
>
> DOESN'T WORK
> <ms:test name='<jsp:getProperty name="cust" property="name"/>'>
You can not use an action element as the attribute value for another
action element.
But since a custom action is just that, custom, you can define any
attributes you like for the action. I find that in many cases it
makes sense to define a number of optional attributes that let you
provide the values the action needs in different ways. For instance,
your <ms:test> action could support the following attributes:
value: the actual String value, or a request-time attribute value
like "<%= foo.getStringValue() %>" if you declare that the attribute
supports request-time expressions.
name + property: the name of a bean in one of the JSP scopes, plus
the property of the bean that contains the value. You need to use
introspection to find and call the bean's property access method
in your custom action tag handler.
param: the name of an HTTP request parameter that contains the
value.
The page author can then use the most appropriate attribute for the
given scenario.
<plug>
My book, JavaServer Pages (O'Reilly), contains examples of how to
develop this type of custom actions. For more details about the
book, see
<http://TheJSPBook.com/>
</plug>
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