How to intercept only the public methods of a bean Managed?

Asked

Viewed 203 times

2

If you have a managed bean ( @Managedbean annotation), how would it be possible to intercept only the public methods of this bean?

The motivation for this would be as follows, suppose you have a bean Controllerbean which can be accessed from a xhtml page. But, you wanted that when any public method of this bean was accessed, it would go through another method before it would check whether the user is allowed to access that area or not. If not, that area would not be accessed.

How can we do that? Could someone give me a functional example?

  • From a glance at Interceptors, I believe it meets your need

  • I do not know if intercepting methods is a suitable solution. What would you do in this method if the user did not have access? Return null? Would you make an exception? That would break the page. What you can do is change the visibility of page elements through the tag rendered according to the permissions of the user. I did this on a system by creating a custom function that queries in Spring Security to see if the user has a certain permission. This allows to control the accesses in a very granular way and improves the usability, because the user only sees what can use.

1 answer

1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.