• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can I create a drop down menu from an enum

 
Tariq Jamal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an enum in my model

Is it possible to create a drop down with the values of the description?

Below is the code. Thanks


 
Ankit Garg
Sheriff
Posts: 9591
34
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I don't know if it is possible using JSTL as I read that you can only pass Collection, Map or array to the forEach tag. You can however use scriptlets which I know is a bad thing to do but I usually use scriptlets in my JSPs so I'm suggesting that...
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would not suggest scriptlets. Ever.

It's easy to use a custom tag, a bean, or the code in the page cntroller to grab the values from the enum to put into a List or Map to be used from the JSTL.

Never, ever, succumb to the tempatation to put scriptlets in your JSP. There's always a better way.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!