Class FieldBase<T, U>
Base class for components that model an entity property, which can be generated by an IEditSpec.
public abstract class FieldBase<T, U> : CancellableComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable, IValidatable<T>, IValidatable where T : IHasChanges where U : IEntity?
Type Parameters
TU
- Inheritance
-
FieldBase<T, U>
- Implements
-
IValidatable<T>
- Derived
- Inherited Members
Properties
FocusChanged
[Parameter]
public EventCallback<bool> FocusChanged { get; set; }
Property Value
HasValue
Indicates whether the validatable field has a value set
public abstract bool HasValue { get; }
Property Value
IsReadOnly
[Parameter]
public bool IsReadOnly { get; set; }
Property Value
IsValid
protected bool IsValid { get; }
Property Value
IsValidationPending
protected bool IsValidationPending { get; set; }
Property Value
Logger
[Inject]
public ILogger<FieldBase<T, U>> Logger { get; set; }
Property Value
MaxLength
[Parameter]
public int MaxLength { get; set; }
Property Value
Parent
public abstract U Parent { get; }
Property Value
- U
Property
[Parameter]
public T? Property { get; set; }
Property Value
- T
Rules
[Parameter]
public IEnumerable<IValidationRule> Rules { get; set; }
Property Value
Services
[Inject]
public IServices Services { get; set; }
Property Value
ValidationContext
[CascadingParameter]
public ValidationContext? ValidationContext { get; set; }
Property Value
ValidationResults
The results of the latest triggered validation(s) for the field
public ValidationResults ValidationResults { get; }
Property Value
ValidationResultsChanged
[Parameter]
public EventCallback<ValidationResults> ValidationResultsChanged { get; set; }
Property Value
Methods
CanParse()
Indicates whether the validatable field has a value that can be parsed
public abstract bool CanParse()
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public override void Dispose()
GetValue()
public T? GetValue()
Returns
- T
HasChanges()
public abstract bool HasChanges()
Returns
NotifyValueChanged()
protected void NotifyValueChanged()
OnAddValidationRules()
Called when the validation rules are added. This allows FieldBase implementations to override this method to provide validation rules at the field level (in addition to those passed in via the Rules parameter)
protected virtual void OnAddValidationRules()
OnAfterRender(bool)
Method invoked after each time the component has rendered interactively and the UI has finished updating (for example, after elements have been added to the browser DOM). Any ElementReference fields will be populated by the time this runs.
This method is not invoked during prerendering or server-side rendering, because those processes are not attached to any live browser DOM and are already complete before the DOM is updated.
protected override void OnAfterRender(bool firstRender)
Parameters
firstRenderboolSet to
trueif this is the first time OnAfterRender(bool) has been invoked on this component instance; otherwisefalse.
Remarks
The OnAfterRender(bool) and OnAfterRenderAsync(bool) lifecycle methods
are useful for performing interop, or interacting with values received from @ref.
Use the firstRender parameter to ensure that initialization work is only performed
once.
OnAfterRenderAsync(bool)
Method invoked after each time the component has been rendered interactively and the UI has finished updating (for example, after elements have been added to the browser DOM). Any ElementReference fields will be populated by the time this runs.
This method is not invoked during prerendering or server-side rendering, because those processes are not attached to any live browser DOM and are already complete before the DOM is updated.
Note that the component does not automatically re-render after the completion of any returned Task, because that would cause an infinite render loop.
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
firstRenderboolSet to
trueif this is the first time OnAfterRender(bool) has been invoked on this component instance; otherwisefalse.
Returns
Remarks
The OnAfterRender(bool) and OnAfterRenderAsync(bool) lifecycle methods
are useful for performing interop, or interacting with values received from @ref.
Use the firstRender parameter to ensure that initialization work is only performed
once.
OnFocusChanged(bool)
protected Task OnFocusChanged(bool focus)
Parameters
focusbool
Returns
OnValidationChanged()
protected virtual void OnValidationChanged()
RequiresValidation()
Marks the field as pending validation
public void RequiresValidation()
Remarks
The field will be responsible for calling validation at the correct time in its rendering pipeline
Validate()
public bool Validate()
Returns
ValidateAsync()
public Task<bool> ValidateAsync()