• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Accessing Constants in Expression Language

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to access a public static constant using the JSP expression language?

Assuming VmOffer.PHONE_NOTIFICIATION_PRIORITY is defined as a public static final string, what is the correct syntax for

<c:if test="${offer.phoneNotificationScheme == VmOffer.PHONE_NOTIFICIATION_PRIORITY}" >
Notification scheme is: PRIORITY
</c:if>

Thanks
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The right part of an EL using the "." has to be a java bean property.

for instance if the EL says ${myBean.xxxx} you should have an instance of the java been with the following methods

getXxxx() and setXxxx()

you can create a getter method that returns the static constant and be able to access using the EL.
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gary, the JavaRanch Journal article referenced at the top of the JSP forum addresses just this issue.

Here's another link.
 
Gary Blomquist
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought about writing a getter method but I was hoping there might be something defined in the EL so I wouldn't have to.

Adding a feature to make public constants accessble using the EL would be a nice enhancement.
 
You guys haven't done this much, have ya? I suggest you study this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic