Build a toolbar through the fluent API¶
Configure a server-rendered toolbar component through a fluent builder chain. Trigger: Razor view calling Html.SAIF().Toolbar().
| Field | Value |
|---|---|
| Operation ID | OP-23 |
| Trigger | Razor view calling Html.SAIF().Toolbar() |
| Inputs | Fluent configuration lambda |
| Outputs | A configured Toolbar whose Render() and ToHtmlString() currently emit no markup |
| Primary components | HtmlHelperExtensions.SAIF into ViewComponentFactory.Toolbar() into ToolbarBuilder.Items(Action<ToolbarItemFactory>) into ToolbarItemFactory.Add() / AddSaveButton() |
| Entry point | src/Web.Mvc/UI/Extensions/HtmlHelperExtensions.cs |
Steps¶
Html.SAIF()wraps the helper in aViewComponentFactory.Toolbar()constructs aToolbarbound toHtmlHelper.ViewContextand wraps it in aToolbarBuilder.Items(addAction)invokes the caller's lambda with aToolbarItemFactorybound to the toolbar and view context.Add()creates an emptyToolbarItem, appends it toToolbar.Items, and returns aToolbarItemBuilder.AddSaveButton()creates aToolbarItempre-populated withId = "lnk-save",ImageUrl = "/Resources/MenuImages/save.png", andTooltip = "Save (Alt + S)"(BR-54).ToolbarItemBuilder, throughNavigationItemBuilder, setsEnabled,Id,Text,Tooltip,Url,Visible, and the three html-attribute dictionaries; eachHtmlAttributes-family setter clears the dictionary before merging. TheActionoverloads (Action(RouteValueDictionary),Action(string, string),Action(string, string, object),Action(string, string, RouteValueDictionary)) andRouteoverloads (Route(string, object),Route(string, RouteValueDictionary)) accept values and discard them.ViewComponentBuilderBase.Render()callsViewComponentBase.Render(), which wrapsViewContext.Writerin anHtmlTextWriterand invokes the virtualWriteHtml— empty inViewComponentBase, andToolbar.WriteHtmlonly callsbase. No output is produced, andToString()returns an empty string.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start(["Html.SAIF().Toolbar()"])
Wrap[Wrap in ViewComponentFactory]
Build[Construct Toolbar and ToolbarBuilder]
Items[Invoke caller lambda via Items]
Add[Add / AddSaveButton items]
Render[Call Render/ToHtmlString]
EndOk([No markup emitted])
Start --> Wrap
Wrap --> Build
Build --> Items
Items --> Add
Add --> Render
Render --> EndOk
Failure and edge-case behavior¶
- The
ActionandRouteoverload no-ops and emptyWriteHtmlmean a renderedToolbarcurrently emits no markup regardless of how it was configured — this may be abandoned work in progress rather than intended behavior.*
Related documentation¶
Note: Statements marked with
*were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with**could not be confirmed; treat as unknown until verified.
Sources¶
src/Web.Mvc/UI/Extensions/HtmlHelperExtensions.cssrc/Web.Mvc/UI/Toolbar/*.cssrc/Web.Mvc/UI/ViewComponentFactory.cs