Presenters depend on a view interface. Extend View for simple attachable elements or Viewable when you expose a DominoElement.
@BrixPresenter
public class AdminPresenter extends Presenter<AdminView> {
@Override
public Set<String> getRoles() {
return Set.of("admin");
}
@Override
public Authorizer getAuthorizer() {
return RolesAllowedAuthorizer.INSTANCE;
}
}
Annotate the implementation with @UiView. The processor generates the binding and Dagger module to inject the view into presenters.
SecurityContext sc = (SecurityContext) Brix.get().getCoreComponent().core().getSecurityContext();
sc.setUser(new MyUser());
sc.setUnauthorizedAccessHandler(() -> window.alert("Access denied"));
Define UI handler interfaces and mark presenter methods with @UiHandler. The generated handler bridges view events to the presenter.
public class DepartmentAuthorizer implements Authorizer {
@Override
public boolean isAuthorized(IsSecurityContext context, HasRoles hasRoles) {
return context.isAuthenticated()
&& context.getUser().getAttributes().get("department").ifTypeIs(String.class, dept -> {
return dept.equals("engineering");
});
}
}
When a presenter uses @RegisterSlots, the processor generates a *Slots interface. Make your view implement it to supply slot instances so the presenter can register them during activation.
Use BrixView or your own View/Viewable implementations. Attach/detach callbacks from IsAttachable allow presenters to react to DOM lifecycle, and implementing CanConfirmNavigation lets the view block navigation while dirty.