Elastic Path Commerce Development

Creating a State Policy aware editor

Creating a State Policy aware editor

Note: Before You Begin

Make sure that you have Creating a State Policy extension point in the plugin.

For a Commerce Manager editor to be State Policies aware, it must extend AbstractPolicyAwareFormEditor.

The following methods must be implemented:

  • getTargetIdentifier
  • addPages

getTargetIdentifier must return the unique identifier that will be used to map Creating a State Policy Contribution to this object.

public String getTargetIdentifier() {
	return "categoryEditor"; //$NON-NLS-1$

addPages is responsible for creating and adding the editor's pages. Before adding pages, you need to add a Policy Action Container. Then use addPage to add pages to the editor. addPage takes the PolicyActionContainer object as its second parameter. This ensures that StateChangeTarget objects are added to the PolicyActionContainer for the UI controls in each page that is added to the editor.

protected void addPages() {
    try {
        final PolicyActionContainer pageContainer = addPolicyActionContainer("categoryEditor"); //$NON-NLS-1$
        addPage(new CategorySummaryPage(this), pageContainer);
        addPage(new CategoryAttributePage(this), pageContainer);
        addPage(new CategorySeoPage(this), pageContainer);
        addPage(new CategoryFeaturedProductsPage(this), pageContainer);
    } catch (final PartInitException e) {
        throw new EpUiException(e);
Note: Use IPolicyTargetComposite

Make sure the pages use PolicyTargetCompositeFactory to create an IPolicyTargetComposite and use its add methods to Adding State Policy aware UI controls.

Registering the editor for Change Sets

In order to edit an object from within a Change Sets, its editor must be registered as a Change Set supported component. To do this, edit the plugin's plugin.xml and add a supportedComponents extension point (if one doesn't already exist). Inside the extension point, add an editor element with an editorId attribute set to the name of your editor class and an objectType attribute containing a display name for the editor. The following example shows the registration for com.elasticpath.cmclient.catalog.editors.category.CategoryEditor.

<extension point="com.elasticpath.cmclient.changeset.supportedComponents">