From: Timo Neumann [mailto:[EMAIL PROTECTED] I have a class Constants that contains entries like that
public static final String YES = "yes";
I want to access these "constants" in my JSPs with EL, something like:
<html:radio property="partner" value="${Constants.YES}"/>
This way it does not work. How would I do it right?
I've got a workaround that is not very elegant and I would like to avoid it:
<c:set var="formRadioYes"><%= Constants.YES %></c:set> <html:radio property="partner" value="${formRadioYes}"/>
The EL can reference javabeans properties, and collection and map entries. That's it (pre-JSP 2.0). It can't reference static variables.
If you have several constants that you want to reference throughout your view side of the application, create a bean in application scope with specific properties, or with a map. It's possible to use reflection to load the "static final" variables from a class into a map.
Thanks, David. -- F&F Computer Anwendungen Tel: +49 89 51727-352 und Unternehmensberatung GmbH Fax: +49 89 51727-111 Westendstr. 195 Mail: [EMAIL PROTECTED] D-80686 Muenchen http://www.ff-muenchen.de
=========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant archives, FAQs and Forums on JSPs can be found at:
http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com