1. Domino Brix
  2. Presenters & views

Presenter basics

Presenters orchestrate lifecycle, routing, slots, events, security, and navigation confirmation around a view. The processor generates the implementation and binds the injected view.

			@BrixPresenter
@BrixRoute("dashboard")
@BrixSlot(BrixSlots.BRIX_BODY_SLOT)
public class DashboardPresenter extends Presenter<DashboardView> {

  @Override
  protected void onRevealed() {
    view.showMessage("Hello, Brix!");
  }
}

		

Lifecycle hooks

Hook into the full lifecycle to prepare UI, react to routing, or clean up resources.

  1. postConstruct(): after DI; register listeners or prime state.
  2. onActivated(): presenter becomes active after auth/guards.
  3. onBeforeRevealed(): right before revealing the view.
  4. onRevealed(): after the view is attached to its slot.
  5. onStateChanged(): routing token changed while active.
  6. onDeactivated(): tear down listeners and timers.
  7. onRemoved(): DOM detach when the slot removes the view.

Navigation confirmation

Views can block navigation when they have unsaved state. Implement CanConfirmNavigation or ProvidesConfirmNavigation to install a router interceptor during activation.

			public class ConfirmingView extends BrixView<Element, FormHandlers>
    implements CanConfirmNavigation {
  private boolean dirty;

  @Override public boolean isConfirmNavigation() { return dirty; }

  @Override
  public void confirmNavigation(ConfirmNavigationHandlers handlers) {
    if (window.confirm("Discard changes?")) handlers.onConfirmed();
    else handlers.onCanceled();
  }
}

		

Routing state parameters

Annotate presenter fields with @PathParameter, @QueryParameter, or @FragmentParameter. Generated setters populate fields before activation and keep them updated on token changes. Override onStateChanged() to react.

Child presenters

Use ChildPresenter to activate only when the parent is active and to share routing state. This keeps child views in sync with parent lifecycle.

			@BrixPresenter
@BrixRoute("details/:id")
@BrixSlot("content-slot")
public class DetailsPresenter extends ChildPresenter<DashboardPresenter, DetailsView> {
  @PathParameter("id") String id;

  @Override
  protected void onActivated() {
    view.loadDetails(id);
  }

  @Override
  public void onBindParent(DashboardPresenter parent) {
    view.setHeader(parent.getHeaderTitle());
  }
}

		

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

Donate & Support Us