In my web application I need to display a drop down dynamically loaded from database.
I need to load the list of users from DB. Each user will have 'access level' as 1 or 2.
When the users are displayed in the dropdown they must have an image in the side of their name.
(like 'Green' tick for 'access level' 1) and (red cross for access level 2).
I have checked this url http://www.marghoobsuleman.com/jquery-image-dropdown.
But I need to to display the image based on the access level loaded from DB.
I guess this can be done by JQuery/CSS.
Can anyone please tell how this can be done and if possible sample code please?
Best Answer
Since you are using jsp as view technology, use core tags to decide whether you want to show green tick or red cross depending upon the access level.
Visit this site to know more about the usage of core tags. Don't forget to include jstl.jar and standard.jar files in your project classpath. They are necessary libraries which support jstl.
Looks like your application is developed using spring framework, so I'll try to explain it that way only.
Your JSP code will be something like this: name it userlist.jsp
Now you will have a controller which will be called after invoking some action and it will return this jsp along with userNameList. Below is sample UserController.java
& User DTO can be something like this. Below is sample User.java
This can't be fully articulated answer. I have tried my best to explain. You give this a try. It should work.