Class UiComponentPolicyContext
java.lang.Object
io.jmix.uiconstraints.accesscontext.UiComponentPolicyContext
- All Implemented Interfaces:
AccessContext
Defines an authorization point for a UI component policy: whether a component or an action of a view may be
shown to the current user, and whether it may be modified by them.
The component is addressed exactly as a policy addresses it - by the id of the view and the path of the
component relative to that view, for example addressFragment.streetField for a component of a
fragment or usersDataGrid.create for an action. Both permissions start as granted, so a component
that no policy mentions is reported as permitted.
Example:
UiComponentPolicyContext context = new UiComponentPolicyContext(viewId, "addressFragment.streetField");
accessManager.applyRegisteredConstraints(context);
if (!context.isVisiblePermitted()) {
// the component must not be shown
}
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable StringReturns a human-readable explanation of constraints applied to the current context instance for logging of authorization decisions.Returns the path of the component or action within the view, in the form used by UI component policies.Returns the id of the view the component belongs to.booleanReturns whether the component may be modified.booleanReturns whether the component may be shown.voidDenies modifying the component: a field is expected to become read-only, any other component disabled.voidDenies showing the component.
-
Field Details
-
viewId
-
componentPath
-
visiblePermitted
protected boolean visiblePermitted -
enabledPermitted
protected boolean enabledPermitted
-
-
Constructor Details
-
UiComponentPolicyContext
-
-
Method Details
-
getViewId
Returns the id of the view the component belongs to. -
getComponentPath
Returns the path of the component or action within the view, in the form used by UI component policies. -
setVisibleDenied
public void setVisibleDenied()Denies showing the component. -
setEnabledDenied
public void setEnabledDenied()Denies modifying the component: a field is expected to become read-only, any other component disabled. -
isVisiblePermitted
public boolean isVisiblePermitted()Returns whether the component may be shown. -
isEnabledPermitted
public boolean isEnabledPermitted()Returns whether the component may be modified. -
explainConstraints
Description copied from interface:AccessContextReturns a human-readable explanation of constraints applied to the current context instance for logging of authorization decisions. Null if the current context does not impose any constraints.- Specified by:
explainConstraintsin interfaceAccessContext
-