Elastic Path Commerce Development

Adding State Policy aware UI controls

Adding State Policy aware UI controls

Use the IPolicyTargetLayoutComposite's add methods to add State Policies aware UI controls. These methods take a PolicyActionContainer object as their final parameter. This ensures that a StateChangeTarget is added to the PolicyActionContainer for each UI control that is added to the composite

If you are Creating a State Policy aware dialog, use the IPolicyTargetLayoutComposite in the createDialogContent method. Otherwise, use the PolicyTargetCompositeFactory to get an IPolicyTargetLayoutComposite instance.

final PolicyActionContainer myPolicyContainer = addPolicyActionContainer("myPolicyContainer"); //$NON-NLS-1$

// Create a grid layout composite
final IEpLayoutComposite gridLayoutComposite =
        CompositeFactory.createGridWrapLayoutComposite(parent, 2, false);

// Wrap it in a State Policy aware layout composite
final IPolicyTargetLayoutComposite policyComposite =
        PolicyTargetCompositeFactory.wrapLayoutComposite(gridLayoutComposite);

// Add UI controls
policyComposite.addLabelBoldRequired("Label", labelData, myPolicyContainer);
policyComposite.addTextField(fieldData, myPolicyContainer);