Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

enum in JSP EL & JSTL

 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I want to use enum in jsp using EL & JSTL, below is code,



above code OWN is hardcoded string in EL,
Instead of using hardcoded string want to use a enum PaymentOerationType having all possible values of payment type.
I am not able to use PaymentOerationType.OWN directly in EL.

How can I deal with emuns in EL or JSTL?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot directly access the enum. What you can dois to use the values() method of the enum to gather the enum values into a Map or List and use it on the page by placing it in request scope.
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

Thanks for reply.

It worked way you told, but just one question in my mind why EL or JSTL does not support a enum?

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dunno. They didn't consult me during the specification phase.
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
:) I was thinking might be some technical reason for that you might know.
anyways thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic