struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Hunt <ad...@revoltingdigits.com>
Subject Re: using Constants from JSTL .....
Date Thu, 08 Jul 2004 11:49:11 GMT
Hmmm, that gives me no error but no result either  I put in the 
following code to test it and just got blank
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
><admin@revoltingdigits.com> 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: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>    
>>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message