Juan Rojas
Juan Rojas

Reputation: 8861

How to create a secure view with Vaadin and SpringViewProvider

There is a tutorial about Vaadin III - Views and Navigation with Vaadin Spring

If I want to use Apache Shiro. How should I use ViewAccessControl?

@SpringComponent
@SpringView(name = SecuredView.VIEW_NAME)
public class SecuredView extends VerticalLayout implements View, ViewAccessControl {

    public static final String VIEW_NAME = "view";

    @PostConstruct
    void init() {
        addComponent(new Label("This is a secured view scoped view"));
    }
    @Override
    public boolean isAccessGranted(UI ui, String string) {
        return true;
    }
}

I get the exception:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securedView': Scope 'vaadin-view' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No active view

Upvotes: 3

Views: 1020

Answers (1)

Adri
Adri

Reputation: 1

The problem is that you're trying to inject the bean in a narrow context. e.g. SpringUI : UIScope => SpringView : ViewScope Try to have a look "inside" annotation, they carry already the SpringComponent Cheers

Upvotes: 0

Related Questions