Table of Contents

Class EditScreenBase<TModel>

Namespace
Dynamicweb.CoreUI.Screens
Assembly
Dynamicweb.CoreUI.dll

Base class for all CoreUI edit screens. Subclass this to create a custom edit screen for a model of type TModel.

public abstract class EditScreenBase<TModel> : ScreenBase<TModel> where TModel : DataViewModelBase, new()

Type Parameters

TModel

The view model type for this edit screen. Must derive from DataViewModelBase and have a public parameterless constructor.

Inheritance
ScreenBase<TModel>
EditScreenBase<TModel>
Derived
Inherited Members

Remarks

Override BuildEditScreen() to define the screen's field layout and GetSaveCommand() to supply the command that persists changes. Use EditorFor(string) or EditorFor<T>(Expression<Func<TModel, T>>) to resolve editors, and AddComponents(string, string, IEnumerable<UiComponentBase?>?) to place them into tabs.

Constructors

EditScreenBase()

Initializes a new instance of the EditScreenBase<TModel> class. Builds the editor mappings from both GetEditorMappings() overrides and ConfigurablePropertyAttribute-decorated model properties.

public EditScreenBase()

Properties

ActiveTabName

Gets or sets the name of the tab that should be made active when the screen first renders. When empty, the first tab is active. Can also be set by the framework when a focused component is on a specific tab.

public string ActiveTabName { get; set; }

Property Value

string

Configuration

Gets or sets the resolved screen configuration, which controls which fields are visible, editable, and in what order. Set automatically before BuildEditScreen() is called.

protected EditScreenConfiguration? Configuration { get; set; }

Property Value

EditScreenConfiguration

DisableLeaveConfirmation

Gets or sets a value indicating whether the browser's unsaved-changes confirmation dialog is suppressed when the user navigates away from this screen.

public bool DisableLeaveConfirmation { get; set; }

Property Value

bool

LayoutCustomization

Gets or sets the active layout customization for this screen, when a screen layout has been configured by an administrator. null when the default tab/group layout is in use.

public EditScreenLayoutCustomization? LayoutCustomization { get; set; }

Property Value

EditScreenLayoutCustomization

MultiEditMode

Gets or sets a value indicating whether this screen is operating in multi-edit mode, where the same screen is used to edit multiple model instances simultaneously.

public bool MultiEditMode { get; set; }

Property Value

bool

ShadowEdit

Gets or sets the shadow-edit session for this screen, used to track staged changes before they are committed. null when shadow editing is not active.

protected ShadowEdit<TModel>? ShadowEdit { get; set; }

Property Value

ShadowEdit<TModel>

ShowManageFields

Gets or sets a value indicating whether the "Manage fields" action is shown on this screen. Defaults to true. Set to false to suppress the action.

protected bool ShowManageFields { get; set; }

Property Value

bool

UpdateTreeAfterSave

Gets or sets a value indicating whether the navigation tree should be refreshed after a successful save. Set to true in BuildEditScreen() when saving may change tree node labels or structure.

protected bool UpdateTreeAfterSave { get; set; }

Property Value

bool

UpdateWorkspaceAfterSave

Gets or sets a value indicating whether the workspace panel should be refreshed after a successful save. Set to true in BuildEditScreen() when saving may change data visible in the workspace.

protected bool UpdateWorkspaceAfterSave { get; set; }

Property Value

bool

Methods

AddComponent(string, string, UiComponentBase?)

Adds a single UI component to the specified tab under the given group heading.

protected void AddComponent(string tabName, string heading, UiComponentBase? component)

Parameters

tabName string

The name of the tab to add the component to. The tab is created if it does not exist.

heading string

The group heading under which the component is placed.

component UiComponentBase

The component to add. ListDisplay components are automatically wrapped in a Widget.

AddComponent(string, string, string, UiComponentBase?)

Adds a single UI component to the specified tab under the given group heading, with an explanatory text.

protected void AddComponent(string tabName, string heading, string explanation, UiComponentBase? component)

Parameters

tabName string

The name of the tab to add the component to. The tab is created if it does not exist.

heading string

The group heading under which the component is placed.

explanation string

An explanatory text shown alongside the group heading.

component UiComponentBase

The component to add. ListDisplay components are automatically wrapped in a Widget.

AddComponents(string, IEnumerable<LayoutWrapper>)

Adds groups of components to the specified tab from a collection of EditScreenBase<TModel>.LayoutWrapper instances. Each wrapper becomes a separate group heading within the tab.

protected void AddComponents(string tabName, IEnumerable<EditScreenBase<TModel>.LayoutWrapper> wrappers)

Parameters

tabName string

The name of the tab. The tab is created if it does not exist.

wrappers IEnumerable<EditScreenBase<TModel>.LayoutWrapper>

The wrappers, each representing a named group of components.

AddComponents(string, string, IEnumerable<UiComponentBase?>?)

Adds multiple UI components to the specified tab under the given group heading.

protected void AddComponents(string tabName, string heading, IEnumerable<UiComponentBase?>? components)

Parameters

tabName string

The name of the tab. The tab is created if it does not exist.

heading string

The group heading under which all components are placed.

components IEnumerable<UiComponentBase>

The components to add. ListDisplay items are automatically wrapped in Widgets.

AddComponents(string, string, string, IEnumerable<UiComponentBase?>?)

Adds multiple UI components to the specified tab under the given group heading, with an explanatory text.

protected void AddComponents(string tabName, string heading, string explanation, IEnumerable<UiComponentBase?>? components)

Parameters

tabName string

The name of the tab. The tab is created if it does not exist.

heading string

The group heading under which all components are placed.

explanation string

An explanatory text shown alongside the group heading.

components IEnumerable<UiComponentBase>

The components to add. ListDisplay items are automatically wrapped in Widgets.

AddDynamicFields(Expression<Func<TModel, FieldGroupCollection>>, bool)

Renders dynamic fields from the given FieldGroupCollection property, optionally using each field group's name as the tab name instead of placing all groups in a single tab.

protected void AddDynamicFields(Expression<Func<TModel, FieldGroupCollection>> expression, bool useGroupsAsTabs)

Parameters

expression Expression<Func<TModel, FieldGroupCollection>>

An expression that returns the FieldGroupCollection from the model.

useGroupsAsTabs bool

When true, each FieldGroup is rendered as its own tab.

AddDynamicFields(Expression<Func<TModel, FieldGroupCollection>>, bool, Func<FieldGroup, IComparable>?)

Renders dynamic fields from the given FieldGroupCollection property, optionally using each field group's name as the tab name, with custom group ordering.

protected void AddDynamicFields(Expression<Func<TModel, FieldGroupCollection>> expression, bool useGroupsAsTabs, Func<FieldGroup, IComparable>? fieldGroupSortingExpression)

Parameters

expression Expression<Func<TModel, FieldGroupCollection>>

An expression that returns the FieldGroupCollection from the model.

useGroupsAsTabs bool

When true, each FieldGroup is rendered as its own tab.

fieldGroupSortingExpression Func<FieldGroup, IComparable>

A function that returns a comparable key used to sort the field groups, or null to preserve source order.

AddDynamicFields(string, Expression<Func<TModel, FieldGroupCollection>>)

Renders dynamic fields from the given FieldGroupCollection property into the specified tab, grouping each FieldGroup under its own collapsible section.

protected void AddDynamicFields(string tabName, Expression<Func<TModel, FieldGroupCollection>> expression)

Parameters

tabName string

The tab to add the dynamic field groups to.

expression Expression<Func<TModel, FieldGroupCollection>>

An expression that returns the FieldGroupCollection from the model.

AddDynamicFields(string, Expression<Func<TModel, FieldGroupCollection>>, Func<FieldGroup, IComparable>?)

Renders dynamic fields from the given FieldGroupCollection property into the specified tab, using the supplied expression to control group ordering.

protected void AddDynamicFields(string tabName, Expression<Func<TModel, FieldGroupCollection>> expression, Func<FieldGroup, IComparable>? fieldGroupSortingExpression)

Parameters

tabName string

The tab to add the dynamic field groups to.

expression Expression<Func<TModel, FieldGroupCollection>>

An expression that returns the FieldGroupCollection from the model.

fieldGroupSortingExpression Func<FieldGroup, IComparable>

A function that returns a comparable key used to sort the field groups, or null to preserve source order.

AddDynamicFields(string, Expression<Func<TModel, FieldGroupCollection>>, string)

Renders dynamic fields from the given FieldGroupCollection property into the specified tab, prepending a prefix string to each generated group heading.

protected void AddDynamicFields(string tabName, Expression<Func<TModel, FieldGroupCollection>> expression, string headingPrefix)

Parameters

tabName string

The tab to add the dynamic field groups to.

expression Expression<Func<TModel, FieldGroupCollection>>

An expression that returns the FieldGroupCollection from the model.

headingPrefix string

A prefix prepended to each group heading, formatted as "{headingPrefix} - {groupName}".

AddDynamicFields(string, Expression<Func<TModel, FieldGroupCollection>>, string, Func<FieldGroup, IComparable>?)

Renders dynamic fields from the given FieldGroupCollection property into the specified tab, prepending a prefix to group headings and applying a custom sort order to groups.

protected void AddDynamicFields(string tabName, Expression<Func<TModel, FieldGroupCollection>> expression, string headingPrefix, Func<FieldGroup, IComparable>? fieldGroupSortingExpression)

Parameters

tabName string

The tab to add the dynamic field groups to.

expression Expression<Func<TModel, FieldGroupCollection>>

An expression that returns the FieldGroupCollection from the model.

headingPrefix string

A prefix prepended to each group heading, formatted as "{headingPrefix} - {groupName}".

fieldGroupSortingExpression Func<FieldGroup, IComparable>

A function that returns a comparable key used to sort the field groups, or null to preserve source order.

BuildEditScreen()

Defines the layout of this edit screen by adding editors to tabs and groups. Called once per request, after the model and configuration are ready.

protected abstract void BuildEditScreen()

Remarks

CreateLanguageSelector<TTranslationEditScreen, TTranslationQuery, TTranslationModel>(IEnumerable<LanguageOption>, string)

Creates a LanguageSelector that navigates to a translation edit screen for each available language option.

protected LanguageSelector CreateLanguageSelector<TTranslationEditScreen, TTranslationQuery, TTranslationModel>(IEnumerable<LanguageSelector.LanguageOption> options, string selectedOption) where TTranslationEditScreen : EditScreenBase<TTranslationModel> where TTranslationQuery : DataQueryModelBase<TTranslationModel>, IIdentifiableModelQuery<TTranslationModel> where TTranslationModel : DataViewModelBase, IIdentifiable, new()

Parameters

options IEnumerable<LanguageSelector.LanguageOption>

The language options to populate the selector with.

selectedOption string

The currently selected language option value.

Returns

LanguageSelector

A configured LanguageSelector that can be returned from GetLanguageSelector().

Type Parameters

TTranslationEditScreen

The edit screen type used to edit translated variants.

TTranslationQuery

The query type that loads a single translated model by identifier.

TTranslationModel

The translated model type.

CreateMapping<T>(Expression<Func<TModel, T>>)

Creates an EditScreenBase<TModel>.EditorMapping for the model property indicated by the expression. Use the returned mapping to register a custom editor binding in GetEditorMappings().

protected EditScreenBase<TModel>.EditorMapping CreateMapping<T>(Expression<Func<TModel, T>> expression)

Parameters

expression Expression<Func<TModel, T>>

A lambda expression pointing to the model property, e.g. m => m.Name.

Returns

EditScreenBase<TModel>.EditorMapping

A new EditScreenBase<TModel>.EditorMapping for the property.

Type Parameters

T

The property value type.

CreateMapping<T>(Expression<Func<TModel, T>>, T)

Creates an EditScreenBase<TModel>.EditorMapping for the model property indicated by the expression, with a fallback value used when the model property returns null.

protected EditScreenBase<TModel>.EditorMapping CreateMapping<T>(Expression<Func<TModel, T>> expression, T fallbackValue)

Parameters

expression Expression<Func<TModel, T>>

A lambda expression pointing to the model property.

fallbackValue T

The value to use when the model does not supply a value for this property.

Returns

EditScreenBase<TModel>.EditorMapping

A new EditScreenBase<TModel>.EditorMapping for the property, pre-configured with the fallback value.

Type Parameters

T

The property value type.

EditorFor(string)

Resolves the editor for the model property with the given system name. Call this from BuildEditScreen() to obtain the editor before placing it on the screen.

protected EditorBase? EditorFor(string name)

Parameters

name string

The system name of the model property (typically the C# property name).

Returns

EditorBase

The resolved EditorBase instance, or null if the editor is hidden, excluded by the current screen configuration, or cannot be resolved.

EditorFor<T>(Expression<Func<TModel, T>>)

Resolves the editor for the model property indicated by the given expression. Call this from BuildEditScreen() to obtain the editor before placing it on the screen.

protected EditorBase? EditorFor<T>(Expression<Func<TModel, T>> expression)

Parameters

expression Expression<Func<TModel, T>>

A lambda expression pointing to the model property, e.g. m => m.Name.

Returns

EditorBase

The resolved EditorBase instance, or null if the editor is hidden, excluded by the current screen configuration, or cannot be resolved.

Type Parameters

T

The property value type.

GetAlert()

protected virtual Alert? GetAlert()

Returns

Alert

GetConfirmSaveCommand()

Returns a command that generates a confirmation message shown to the user before the save command is executed. Called once when building the form's submit action.

protected virtual ShowMessageGenerateCommandBase<TModel>? GetConfirmSaveCommand()

Returns

ShowMessageGenerateCommandBase<TModel>

A ShowMessageGenerateCommandBase<T> that produces the confirmation message, or null to save without a confirmation prompt.

GetDefinitionInternal()

Builds and returns the raw component tree for this screen.

protected override sealed UiComponentBase GetDefinitionInternal()

Returns

UiComponentBase

Remarks

Implement this method in every concrete screen class. The result is post-processed by GetDefinition() (injectors, trimming, preset actions) before being returned to the framework.

GetEditor(string)

Returns a custom EditorBase for the given property name, overriding the default editor that would otherwise be resolved from the editor provider. Called during editor resolution for each property.

protected virtual EditorBase? GetEditor(string property)

Parameters

property string

The property name for which a custom editor is requested.

Returns

EditorBase

A custom editor instance, or null to fall back to the default editor.

GetEditorMappings()

Returns the initial set of EditScreenBase<TModel>.EditorMapping instances that define how model properties map to editors. Called once during construction.

protected virtual IEnumerable<EditScreenBase<TModel>.EditorMapping>? GetEditorMappings()

Returns

IEnumerable<EditScreenBase<TModel>.EditorMapping>

A collection of EditScreenBase<TModel>.EditorMapping instances, or null to rely solely on ConfigurablePropertyAttribute-decorated model properties for editor discovery.

GetExplanation(string)

Returns an optional explanatory text shown below the editor for the given property. Called during editor construction when no explanation is already set on the editor.

protected virtual string? GetExplanation(string propertyName)

Parameters

propertyName string

The system name of the model property.

Returns

string

An explanation string, or null to use the default from the model attribute.

GetHint(string)

Returns an optional hint text shown as a tooltip or helper label for the editor of the given property. Called during editor construction when no hint is already set on the editor.

protected virtual string? GetHint(string propertyName)

Parameters

propertyName string

The system name of the model property.

Returns

string

A hint string, or null to use the default from the model attribute.

GetLanguageSelector()

Returns the language-selector action node rendered in the screen's action bar, enabling switching between translation variants of the model. Called once when building the screen layout.

protected virtual LanguageSelector? GetLanguageSelector()

Returns

LanguageSelector

A LanguageSelector node, or null to hide the selector.

GetModelIdentifier()

Returns a string identifier for the current model instance, used to link command-log entries to this record.

protected virtual string? GetModelIdentifier()

Returns

string

The model's identifier string when TModel implements IIdentifiable; otherwise null.

GetOnCloseNavigateAction()

Returns the navigation action executed when the user closes (cancels) the screen. Called once when building the save/cancel button bar.

protected virtual NavigateScreenAction? GetOnCloseNavigateAction()

Returns

NavigateScreenAction

A NavigateScreenAction to navigate to after cancel, or null to use the default back action.

GetOnSaveTreePath()

Returns the tree path that should be reloaded after a successful save when UpdateTreeAfterSave is true. Called when constructing the post-save action chain.

protected virtual string? GetOnSaveTreePath()

Returns

string

A tree path string, or null to reload the current tree node.

GetSaveCommand()

Returns the command responsible for persisting the model data when the user saves. Called once when building the form's submit action and save buttons.

protected virtual CommandBase<TModel>? GetSaveCommand()

Returns

CommandBase<TModel>

A CommandBase<T> that saves the model, or null to render the screen without any save button.

GetScreenActions()

Returns the action groups added to the screen's context action bar (top-right area). Called once when building the screen layout.

protected virtual IEnumerable<ActionGroup>? GetScreenActions()

Returns

IEnumerable<ActionGroup>

A collection of ActionGroup instances, or null to add no actions.

GetScreenName()

Returns the display name shown in the screen's title bar. Called once when building the screen layout.

protected abstract string GetScreenName()

Returns

string

A human-readable name for the screen.

SetInfobar(InfoBar?)

Sets the info bar displayed at the top of the screen layout. Call from BuildEditScreen() to show alerts, warnings, or informational messages.

protected void SetInfobar(InfoBar? bar)

Parameters

bar InfoBar

The InfoBar to display, or null to remove any existing info bar.

SetTabInfobar(InfoBar?)

Sets the info bar displayed inside the tab container, above the tab content but below the tab strip. Call from BuildEditScreen() to show tab-level messages.

protected void SetTabInfobar(InfoBar? bar)

Parameters

bar InfoBar

The InfoBar to display, or null to remove any existing tab info bar.

To top