Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

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);