• Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing Constants in Expression Language

 
Gary Blomquist
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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
 
Ernesto Leyva
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!