1. Domino Brix
  2. Views & handlers

Define the view contract

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;
  }
}

		

Implement with @UiView

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"));

		

UI handlers: view → presenter

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");
           });
  }
}

		

Slot-aware views

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.

We are a group of passionate people who love what we do

Donate & Support Us