Class AdditionalActionWithNestedForm<TProperties, TClientProperties, TModel>
Represents an additional action that contains a model-driven nested form.
public abstract class AdditionalActionWithNestedForm<TProperties, TClientProperties, TModel> : AdditionalAction<TProperties, TClientProperties>, IAdditionalAction where TProperties : AdditionalActionProperties, new() where TClientProperties : AdditionalActionWithNestedFormClientProperties, new() where TModel : new()
Type Parameters
TPropertiesTClientPropertiesTModel
- Inheritance
-
objectAdditionalAction<TProperties, TClientProperties>AdditionalActionWithNestedForm<TProperties, TClientProperties, TModel>
- Implements
- Inherited Members
- Extension Methods
Constructors
AdditionalActionWithNestedForm(IFormItemCollectionProvider, IFormDataBinder, ILocalizationService, IEventLogService, IFormComponentCommandInvoker)
Initializes an instance of the AdditionalActionWithNestedForm<TProperties, TClientProperties, TModel> class.
protected AdditionalActionWithNestedForm(IFormItemCollectionProvider formItemCollectionProvider, IFormDataBinder formDataBinder, ILocalizationService localizationService, IEventLogService eventLogService, IFormComponentCommandInvoker formComponentCommandInvoker)
Parameters
formItemCollectionProviderIFormItemCollectionProviderformDataBinderIFormDataBinderlocalizationServiceILocalizationServiceeventLogServiceIEventLogServiceformComponentCommandInvokerIFormComponentCommandInvoker
Properties
Model
Gets edited model that represents the form.
protected abstract TModel Model { get; }
Property Value
- TModel
SuccessMessageKey
Gets or sets the success message displayed after submitting the form.
protected virtual string SuccessMessageKey { get; }
Property Value
- string
Methods
BindComponentsToModel(TModel, ICollection<IFormComponent>)
Binds values of components to edited model.
protected void BindComponentsToModel(TModel model, ICollection<IFormComponent> components)
Parameters
modelTModelModel to bind values retrieved from form components.
componentsICollection<IFormComponent>Form components to bind data from.
BindContextToComponents(ICollection<IFormComponent>)
Binds context to form components.
protected Task BindContextToComponents(ICollection<IFormComponent> components)
Parameters
componentsICollection<IFormComponent>Form components.
Returns
- Task
BindDataToComponents(ICollection<IFormComponent>, Dictionary<string, JsonElement>, CancellationToken)
Binds data to form components in components.
protected Task<IFormFieldValueProvider> BindDataToComponents(ICollection<IFormComponent> components, Dictionary<string, JsonElement> data, CancellationToken cancellationToken)
Parameters
componentsICollection<IFormComponent>Components to bind data to.
dataDictionary<string, JsonElement>Data to be bound.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<IFormFieldValueProvider>
Form field value provider.
BindDataToComponentsAndValidate(ICollection<IFormComponent>, Dictionary<string, JsonElement>)
Binds data to form components in components.
Visible components are validated.
protected Task<IFormFieldValueProvider> BindDataToComponentsAndValidate(ICollection<IFormComponent> components, Dictionary<string, JsonElement> data)
Parameters
componentsICollection<IFormComponent>Components to bind data to.
dataDictionary<string, JsonElement>Data to be bound.
Returns
- Task<IFormFieldValueProvider>
Form field value provider.
Change(FormChangeCommandArguments, CancellationToken)
Handles the form change command. The command is invoked whenever visibility conditions of the form need to be reevaluated to re-render the form.
[FormComponentCommand]
public virtual Task<ICommandResponse<FormChangeResult>> Change(FormChangeCommandArguments args, CancellationToken cancellationToken)
Parameters
argsFormChangeCommandArgumentsForm change arguments.
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
- Task<ICommandResponse<FormChangeResult>>
Returns the form change result.
ComponentCommand(FormComponentCommandModel, CancellationToken)
Handles the form component command invocation.
[FormComponentCommand]
public virtual Task<object> ComponentCommand(FormComponentCommandModel commandModel, CancellationToken cancellationToken)
Parameters
commandModelFormComponentCommandModelForm component command arguments.
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
- Task<object>
Returns the form component command result.
ConfigureClientProperties(TClientProperties)
Configures client properties before the form is sent to a client.
protected override Task ConfigureClientProperties(TClientProperties clientProperties)
Parameters
clientPropertiesTClientProperties
Returns
- Task
GetClientFormItems(IEnumerable<IFormItem>)
Returns a collection of client item properties for given form items.
protected virtual Task<ICollection<IFormItemClientProperties>> GetClientFormItems(IEnumerable<IFormItem> formItems)
Parameters
formItemsIEnumerable<IFormItem>Form items.
Returns
- Task<ICollection<IFormItemClientProperties>>
GetFormItems()
public virtual Task<ICollection<IFormItem>> GetFormItems()
Returns
- Task<ICollection<IFormItem>>
Remarks
Override the method in case when additional set-up of form components is required.
GetFormItemsClientProperties()
Returns properties describing client form items for editing the Model.
protected virtual Task<IEnumerable<IFormItemClientProperties>> GetFormItemsClientProperties()
Returns
- Task<IEnumerable<IFormItemClientProperties>>
InitializeContext()
Initializes form context.
protected virtual Task<IFormContext> InitializeContext()
Returns
- Task<IFormContext>
ProcessFormData(TModel, ICollection<IFormItem>)
Processes the model and creates a response for the Submit(FormSubmissionCommandArguments) command.
protected virtual Task<ICommandResponse> ProcessFormData(TModel model, ICollection<IFormItem> formItems)
Parameters
modelTModelModel to be processed.
formItemsICollection<IFormItem>Form items with bound component values.
Returns
- Task<ICommandResponse>
The response to be used for the Submit(FormSubmissionCommandArguments) command.
ResponseFrom<TResult>(TResult)
Returns a command response from the passed result.
protected ICommandResponse<TResult> ResponseFrom<TResult>(TResult result)
Parameters
resultTResultResult of the command processed on the additional action.
Returns
- ICommandResponse<TResult>
Type Parameters
TResultType of the returned result.
Submit(FormSubmissionCommandArguments)
Handles the form submit command.
[FormComponentCommand]
public virtual Task<ICommandResponse> Submit(FormSubmissionCommandArguments args)
Parameters
argsFormSubmissionCommandArgumentsForm submission arguments.
Returns
- Task<ICommandResponse>
Returns the form submission result.
Remarks
The default implementation calls the SubmitInternal(FormSubmissionCommandArguments, ICollection<IFormItem>, IFormFieldValueProvider) method.
- See Also
SubmitInternal(FormSubmissionCommandArguments, ICollection<IFormItem>, IFormFieldValueProvider)
Handles the internal specific processing of form submit command.
protected virtual Task<ICommandResponse> SubmitInternal(FormSubmissionCommandArguments args, ICollection<IFormItem> items, IFormFieldValueProvider formFieldValueProvider)
Parameters
argsFormSubmissionCommandArgumentsForm submission arguments.
itemsICollection<IFormItem>Form items with bound component values.
formFieldValueProviderIFormFieldValueProviderProvider of form field values.
Returns
- Task<ICommandResponse>
Returns the form submission result.
Remarks
This method is called by the default implementation of the Submit(FormSubmissionCommandArguments) method.
- See Also