• Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying Roles in JSTL

 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Now, i have two objects returning from my controller, they are availableRoles and havingroles. In my JSP page, i need to display all the available roles and check whether user is having that role, i.e in havingRoles, if yes check the checkbox. I know to use forEach is JSTL. Can you please tell me how to proceed with this task.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems pretty straight-forward, no? What specifically is giving you a problem?

Although to be honest, I'd do more of this work on the server side, or use a map, or something, otherwise you'll end up doing nested loops.
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David for the reply, now i am bothered with how to check for roles in having Roles. i.e how can we check for havingRoles.contains(availableRoles.get(i)) in JSTL. Also, can you please elaborate on which you told that, you will be doing that in a server side..
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The EL cannot access general methods in a class -- it expects the information passed to the JSP to be patterned as beans. So you should be exposing your role information in a way that's suitable for the JSP, rather than trying to contort the JSP into accessing information that's poorly suited for the task.

Perhaps this article might be helpful.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!