Package com.onec.ui

Class PageBuilder

java.lang.Object
com.onec.ui.PageBuilder

public final class PageBuilder extends Object
Composes a Page's content: an optional header, a grid of dashboard widgets, and freeform PageComponent blocks. Widgets reuse the same builder as UiLayoutBuilder.widget(...), so the full widget config (type, entity, calendar/kanban/chart options) is available here.

Rendered order is header → widget grid → components.

  • Constructor Details

    • PageBuilder

      public PageBuilder()
  • Method Details

    • title

      public PageBuilder title(String title)
    • subtitle

      public PageBuilder subtitle(String subtitle)
    • widget

      public UiLayoutBuilder.WidgetBuilder widget(String title)
      Add a dashboard widget; returns the widget builder for further config.
    • text

      public PageBuilder text(String text)
      Add a freeform text block.
    • constants

      public PageBuilder constants()
      Add the app-settings editor — the @Constant values rendered as toggles/inputs and saved in place. A page (e.g. the Settings page) composes this alongside widgets and lists, so settings are just another page built from the framework's primitives.
    • constants

      public PageBuilder constants(String heading)
      Add the settings editor under an optional section heading.
    • constants

      public PageBuilder constants(String heading, String... names)
      Add the settings editor under an optional section heading, restricted to the named @Constants (by their @Constant(name=...) logical name). With no names the whole editor is shown; with names you can drop a single toggle (or a small group) onto any page — a dashboard, or a catalog page authored at that route — not just the Settings page.
    • actions

      public PageBuilder actions(String heading, Consumer<ActionSpec> configurer)
      Add a section of action buttons — each runs an обработка-style server handler (or routes the client) when clicked. Reuses the same ActionSpec DSL as entity actions, but the buttons live on the page itself rather than a list toolbar, so triggering backend logic is a first-class page primitive:
       b.actions("Reports", a -> {
           a.action("createDrafts").label("Create draft reports").icon("file-plus")
            .handler(ctx -> { reports.createDrafts(); return ActionResult.refresh("Drafts created"); });
           a.action("postPending").label("Post pending drafts").icon("send")
            .handler(ctx -> { reports.postPending(); return ActionResult.message("Posted"); });
       });
       

      A button's server handler runs only for an authenticated user; because a page action has no entity to gate on, the handler enforces its own authorization via ctx.user().

    • custom

      public PageBuilder custom(String customType, Map<String,Object> payload)
      Add a div-custom extension block (chart, kanban, ...).
    • list

      public PageBuilder list(Class<?> entity)
      Embed the full interactive list of a catalog/document — the same surface as its own route, with the New button, custom action buttons, search/sort and rows that open a detail beside the page. Lets a page (e.g. Settings) manage reference data inline. entity is the catalog or document class.
    • title

      public String title()
    • subtitle

      public String subtitle()
    • widgets

    • components

      public List<PageComponent> components()
    • pageActions

      public List<ActionSpec.Action> pageActions()
      The page's action-button handlers, in declaration order (resolved by key on post-back).
    • pageAction

      public ActionSpec.Action pageAction(String key)
      The page action with this key, or null if the page declares none.