struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Hunt <ad...@revoltingdigits.com>
Subject using Constants from JSTL .....
Date Wed, 07 Jul 2004 18:01:19 GMT
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 like so
<c:out value="${Constants.FOR_RENTAL_PROPERTIES_SELECTION}"/>

The address is 
http://forum.java.sun.com/thread.jsp?forum=45&thread=508847&message=2415101 
<http://forum.java.sun.com/thread.jsp?forum=45&thread=508847&message=2415101>

This works with a lot of stuff but the jstl and struts tags seem to be a 
little inconsistent in their behaviors.

For example this works ...

snip=
<html:select property="propertyTypes" multiple="true">
            <html-el:optionsCollection 
name="${Constants.PROPERTY_TYPES_SET}" value="id" label="name"/>
         </html:select>
=snip

But for some reason ( my stupidity and the time of the evening ) I 
cannot get this to work.
snip=
<c:set var="emailNotifications" 
value="${scope['Constants.EMAIL_NOTIFICATIONS']"></c:set>
<c:out value="${emailNotifications.priceRangeStart}"/>
=snip

or like this

snip=
<c:set var="emailNotifications" 
value="${scope[${Constants.EMAIL_NOTIFICATIONS}]"></c:set>
<c:out value="${emailNotifications.priceRangeStart}"/>
=snip

I'm starting to feel like I'm back in my Perl days again .... Is there a 
way that I can dereference these
beans or do I have to use sloppy string literals in my jstl code ?

Any suggestions or am I just stupid to want to do this ?

--b






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


Mime
View raw message