This blog is mainly about Java...

Tuesday, July 14, 2009

Injecting checking of roles in Seam

It is well known that you can perform
#{s:hasRole('admin')}
on the view.
You can easily check for the role of the logged in user, by injecting the same thing.

@In(value = "#{s:hasRole('admin')}")
private boolean isAdmin;
If the user has a role of admin the boolean is set to true. You can also use the static method,
Identity.instance().checkRole("admin");

But the former is nicer right?

Labels