screen.
snip=
<jsp:useBean id="Constants" class="ie.jestate.web.Constants"/>
<c:set var="emailNotifications" value="${scope[${Constants.EMAIL_NOTIFICATIONS}]}"></c:set>
<c:out value="${emailNotifications}"/>
<c:out value="${emailNotifications.priceRangeStart}"/>
<c:out value="${emailNotifications.priceRangeEnd}"/>
<c:forEach items="${emailNotifications.urbanAreas}" var="urbanArea">
<c:out value="${urbanArea.name}"/>
</c:forEach>
=snip
If I substitute the following line instead it works fine. <c:set var="emailNotifications" value="${EMAIL_NOTIFICATIONS}"></c:set>
This line of code ... <c:out value="${Constants.EMAIL_NOTIFICATIONS}"/>
Outputs EMAIL_NOTIFICATIONS on the screen.
I think this is starting to look like it just isn't going to work, I don't think that jstl is too smart about dynamic
variables like this. I tried the other suggestion as well (
c:set var="const" value="${scope['Constants']}"/> <c:set var="emailNotifications" value="${const['EMAIL_NOTIFICATIONS']}"/> )
But it didn't work either, this is starting to look as though it will be so convoluted that I might as well not be trying to use constants anyhow as I will have to look up the file anyway I might as well just use string literals.
Cause it isn't scriptlet I wont get auto-completion anyhow. I'm going to try the suggestion from Rick Reumann and then I'm gonna throw my computer out the window.
--b
Denis Avdic wrote:
Have you tried <c:set var="emailNotifications" value="${scope[Constants.EMAIL_NOTIFICATIONS]"/>
?
On Wed, 07 Jul 2004 20:12:02 +0200, Bryan Hunt
<[EMAIL PROTECTED]> wrote:
Just as an addition I can do this
<jsp:useBean id="Constants" class="ie.jestate.web.Constants"/>
<c:set var="emailNotifications" value="${EMAIL_NOTIFICATIONS}"></c:set>
<c:out value="${emailNotifications.priceRangeStart}"/> <c:out value="${emailNotifications.priceRangeEnd}"/> <c:forEach items="${emailNotifications.urbanAreas}" var="urbanArea"> <c:out value="${urbanArea.name}"/> </c:forEach>
And it works fine, but really what I am trying to get here is the value of using Constants in both my Actions and my ( JSTL based ) jsp's.
Perhaps this is just something that never occured to the writers of the JSTL spec ?
--b
Bryan Hunt wrote:
Ok, tearing my hair out right now and extremely confused.
If you look at the Java Technology Forums you will see a rather nice little pattern that someone called evnafets has created, it allows you to use a single Constants class both in your Actions and in your JSP pages ...
It uses reflection to add it's static final members to a map which can
then be accessed by JSTL lik
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]