DwsPageBaseComponent
The DwsPageBaseComponent is a base component that provides a consistent layout and structure for your pages. Below are examples of how to use this component.
Interface Description DwsPageBaseComponentRender error handling
Demonstrates component render exceptions and centralized error callback handling.
Show Code
RenderErrorExsamplePage.razor
@* RenderErrorExsamplePage.razor *@
<DwsPageBaseComponent PageTitle="Render Error Example" PageName="ExampleLoadingPage"
OnPreLoadDataAsync="PreLoad" OnLoadDataAsync="LoadData" OnPostLoadDataAsync="PostLoadData">
<Content>
@if (_pageState == null || !_pageState.Success)
{
<DwsAlert Name="Example_LoadError" Severity="DwsSeverity.Error" Message="Error loading data." />
}
else
{
@* Throws while the content renders: the error boundary around Content shows the page's error state. *@
@RenderContentWithError()
}
</Content>
</DwsPageBaseComponent>@code
private WeatherPageState? _pageState;
private Task PreLoad((DwsPageBaseComponent dwsPageReference, CancellationToken cancellationToken) args)
{
_pageState = new WeatherPageState { Success = true };
return Task.CompletedTask;
}
private Task LoadData((bool firstRun, DwsPageBaseComponent dwsPageReference, CancellationToken cancellationToken) args)
{
_pageState = new WeatherPageState { Success = true };
return Task.CompletedTask;
}
private Task PostLoadData((bool firstRun, DwsPageBaseComponent dwsPageReference, CancellationToken cancellationToken) args)
=> Task.Delay(1000, args.cancellationToken);
private RenderFragment RenderContentWithError() => builder =>
{
throw new InvalidOperationException("Deliberate exception thrown during rendering.");
};
private sealed class WeatherPageState
{
public bool Success { get; set; }
}Interface-Description
| Name | Typ | Parameters | Description |
|---|---|---|---|
| SetUnsavedDataState | Task | Sets the unsaved-data flag used by unload prompts and navigation protection. |
| Name | Typ | Default | Description |
|---|---|---|---|
| OnError | EventCallback<Exception> | default | Called for page-level exceptions captured during rendering and lifecycle execution. |
| ExposeErrorDetails | bool? | null | Shows the exception message and stack trace below the error alert. Unset: only in the Development environment (IDwsEnvironmentInfo), never when the host does not tell its environment. Set it to true or false to decide yourself. |
| OnAfterRenderCallback | EventCallback<bool> | default | Invoked after each render with firstRender indicator. |
| OnAfterRenderSyncCallback | EventCallback<bool> | default | Synchronous counterpart for post-render actions. |
| Name | Typ | Default | Description |
|---|---|---|---|
| Element | ElementReference | The associated web component. May be null if accessed before the component is rendered. | |
| ComponentGuid | Guid | Unique identifier for the component. | |
| TypeString | string | The name of the component type, obtained from reflection. | |
| Authorized_RegisterEnabled | bool | false | Indicates whether this component is enabled through a permission registry. |
| Authorized_RegisterSelected | bool | false | Indicates whether this component is selected in permission selection mode. |
| GetInitializedState | bool | false | Returns whether the component is initialized. |
| GetRenderModeState | DwsRenderMode | Returns the current render mode. | |
| GetComponentState | DwsComponentStateType | Returns the current component state. | |
| GetIsInteractiveState | bool | false | Returns whether the component is interactive. |
| GetIsPrerenderingState | bool | false | Returns whether the component is prerendering. |
| GetComponentLoadingState | bool | false | Returns whether the component is loading. |
| IsFormBusy | bool | false | Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState). |
| Name | Typ | Parameters | Description |
|---|---|---|---|
| DebugInfo | void | Logs debug information about the component. | |
| UpdateState | void | Updates the component's state and triggers StateHasChanged. | |
| UpdateStateAsync | Task | Asynchronously updates the component's state and triggers StateHasChanged. | |
| Dispose | void | Disposes the component and releases resources. | |
| FocusAsync | ValueTask | bool containedInScrollableList | Sets focus to the component's element. |
| Name | Typ | Default | Description |
|---|---|---|---|
| Name | string | Required unique identifier for the component within its container. | |
| Visible | bool | true | Determines if the component is visible in the UI. |
| Disabled | bool | false | Disables the form control, ensuring it doesn't participate in form submission. |
| ComponentNameSpace | string | The namespace for permission-based access control. | |
| PermissionKey | string? | null | A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins. |
| Class | string | Optional CSS class names. | |
| Style | string | Optional in-line styles. | |
| Tag | object | An optional user-defined object to store any additional data with the component. | |
| BackReference | DwsReference | A reference to the enclosing component. | |
| ID | string | The HTML ID attribute for the component. | |
| AdditionalAttributes | Dictionary<string, object> | Additional HTML attributes for the component's root element. | |
| IgnorePermissionChecks | bool | false | Bypasses all permission checks for this component. |
| IgnorePermissionSelection | bool | false | Ignore permission selection mode for this component. |
| IgnoreFormBusy | bool | false | Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it. |
| Name | Typ | Description |
|---|---|---|
| OnInitializedCallbackStarted | EventCallback | Callback when OnInitialized starts. |
| OnInitializedCallback | EventCallback | Callback during OnInitialized. |
| OnInitializedCallbackCompleted | EventCallback | Callback when OnInitialized completes. |
| OnInitializedAsyncCallbackStarted | EventCallback | Callback when OnInitializedAsync starts. |
| OnInitializedAsyncCallback | EventCallback | Callback during OnInitializedAsync. |
| OnInitializedAsyncCallbackCompleted | EventCallback | Callback when OnInitializedAsync completes. |
| OnIsComponentLoadingChanged | EventCallback<bool> | Callback when IsComponentLoading changes. |
| OnCurrentRenderModeChanged | EventCallback<DwsRenderMode> | Callback when CurrentRenderMode changes. |
| OnComponentStateChanged | EventCallback<DwsComponentStateType> | Callback when ComponentState changes. |
