Class FormComponent<TProperties, TClientProperties, TValue>
Represents a base class for UI form component containing members used by the system.
public abstract class FormComponent<TProperties, TClientProperties, TValue> : IFormComponent, IFormItem<IFormComponentClientProperties>, IFormItem where TProperties : FormComponentProperties, new() where TClientProperties : FormComponentClientProperties<TValue>, new()
Type Parameters
TPropertiesTClientPropertiesTValue
- Inheritance
-
objectFormComponent<TProperties, TClientProperties, TValue>
- Implements
- Derived
-
FormComponent<TClientProperties, TValue>
- Extension Methods
Constructors
FormComponent()
Initializes a new instance of the FormComponent<TClientProperties, TValue> class for the specified properties type.
protected FormComponent()
FormComponent(ILocalizationService)
Initializes a new instance. Use this constructor directly only for testing purposes.
protected FormComponent(ILocalizationService localizationService)
Parameters
localizationServiceILocalizationService
Properties
AdditionalActions
Gets the list of additional actions associated with the form component.
public IList<IAdditionalAction> AdditionalActions { get; }
Property Value
- IList<IAdditionalAction>
- See Also
ClientComponentName
Name of the front-end type implementing the UI form component.
public abstract string ClientComponentName { get; }
Property Value
- string
FormContext
Context of the form where the component is used.
public IFormContext FormContext { get; }
Property Value
Guid
Gets or sets the underlying field GUID.
public Guid Guid { get; }
Property Value
- Guid
HasDependencies
Gets or sets the value indicating whether evaluation of a visibility condition of some other component depends on this component's value.
public bool HasDependencies { get; }
Property Value
- bool
Name
Gets the underlying field name.
public string Name { get; }
Property Value
- string
Properties
Gets the server component properties.
public TProperties Properties { get; init; }
Property Value
- TProperties
Required
Gets or sets value indicating whether the underlying field is required. False by default. If false, the form component's implementation must accept nullable input.
public bool Required { get; }
Property Value
- bool
ValidationRules
Gets the list of validation rules associated with the form component.
public IList<IValidationRule> ValidationRules { get; }
Property Value
- IList<IValidationRule>
- See Also
VisibilityConditions
Gets the list of visibility conditions associated with the form component.
public IList<IVisibilityCondition> VisibilityConditions { get; }
Property Value
- IList<IVisibilityCondition>
- See Also
Methods
AddAdditionalAction(IAdditionalAction)
Adds a new additional action.
public virtual void AddAdditionalAction(IAdditionalAction additionalAction)
Parameters
additionalActionIAdditionalActionAdditional action to be added.
Exceptions
- ArgumentNullException
Thrown when
additionalActionis null.- InvalidOperationException
Thrown when there is already another additional action with the same Identifier.
AddValidationRule(IValidationRule)
Adds a new validation rule.
public virtual void AddValidationRule(IValidationRule validationRule)
Parameters
validationRuleIValidationRuleValidation rule to be added.
Exceptions
- ArgumentNullException
Thrown when
validationRuleis null.
AddVisibilityCondition(IVisibilityCondition)
Adds a new visibility condition.
public virtual void AddVisibilityCondition(IVisibilityCondition visibilityCondition)
Parameters
visibilityConditionIVisibilityConditionVisibility condition to be added.
Exceptions
- ArgumentNullException
Thrown when
visibilityConditionis null.
BindContext(IFormContext)
Binds context to the form component.
public virtual Task BindContext(IFormContext context)
Parameters
contextIFormContextContext to be used.
Returns
- Task
Remarks
This method is called later than ConfigureComponent() method.
ConfigureClientProperties(TClientProperties)
Configures the form component client properties.
protected virtual Task ConfigureClientProperties(TClientProperties clientProperties)
Parameters
clientPropertiesTClientPropertiesThe current instance of the form component client properties.
Returns
- Task
Remarks
Override this method in order to configure form component client properties.
ConfigureComponent()
Configures the form component. This method is called when all form component properties are set.
protected virtual void ConfigureComponent()
Remarks
Override this method to set component inner state, like additional component validation rules.
GetClientProperties()
public Task<IFormComponentClientProperties> GetClientProperties()
Returns
GetValue()
Gets the value of the form component.
public virtual TValue GetValue()
Returns
- TValue
Returns the value of the form component.
Remarks
The value can be additionally modified before it is retrieved for data propagation.
ResponseFrom<TResult>(TResult)
Returns a form component command response from the passed result.
protected ICommandResponse<TResult> ResponseFrom<TResult>(TResult result)
Parameters
resultTResultResult of the command processed on the client template.
Returns
- ICommandResponse<TResult>
Type Parameters
TResultType of the returned result.
Remarks
The result is passed to the command after handler.
SetValue(TValue)
Sets the value of the form component.
public virtual void SetValue(TValue value)
Parameters
valueTValueValue to be set.
Remarks
The value can be additionally modified for component usage.
Component is fully configured when method is called.