Show TOC

Step 2: Creating a PCM Wizard ComponentLocate this document in the navigation structure

Use

Each PCM wizard contains a PCM wizard component, whose Java class extends AbstractPCMWizard . This class is descended from AbstractPortalComponent , making the wizard a standard iView that can be displayed in the portal administration pages.

AbstractPCMWizard enables you to implement several methods for handling the following tasks:

  • Adding user panes, which are in addition to the ones automatically added to the wizard by the AbstractPCMWizard class.

  • Setting transitions between panes.

  • Setting dependencies between data model objects. This is not so important because data entered into the wizard by an administrator can be automatically synchronized to the properties of the portal object to be created, and does not require use of the wizard framework data model

  • Modifying the text that is displayed in the Summary pane.

  • Modifying the property values that are saved to the portal object to be created. This allows you to make last-minute changes to the values entered by the administrator.

Procedure
  1. Create a new class that extends AbstractPCMWizard .

  2. Implement addUserPanes() , which has the following signature:

                      protected void addUserPanes(IConfigurableWizard wizard) {
    }
    
                   

    Add the panes for the wizard by calling addPane() on the IConfigurableWizard object passed into the method, as follows:

                      wizard.addPane(ServerInfo.SERVER_INFO_PANE_KEY,
        ServerInfo.class.getName());
                   

    The above assumes that ServerInfo is the name of a class that defines a pane, as described in Step 1: Creating User Panes .

  3. Implement addTransitions() , which has the following signature:

                      protected void addUserTransitions(IConfigurableWizard wizard) {
    }
    
                   

    Add transitions between the wizard panes. For more information on transitions, see Wizard Framework Objects .

    The wizard automatically starts the Info pane. You must supply transitions from this pane. The following example creates a wizard that displays the built-in Info pane, the custom UserInfo pane, the custom ServerInfo pane, and then the built-in Summary and Finish panes, in that order:

                      //Built-in Info pane to custom UserInfo pane
    wizard.addTransition(START_PANE, NEXT, null,
        UserInfo.USER_INFO_PANE_KEY);
     
    //UserInfo pane to custom ServerInfo pane
    wizard.addTransition(UserInfo.USER_INFO_PANE_KEY, NEXT ,null,
        ServerInfo.SERVER_INFO_PANE_KEY);
     
    //ServerInfo pane to built-in Summary and Finish panes
    wizard.addTransition(ServerInfo.SERVER_INFO_PANE_KEY, NEXT ,null,
        END_PANE);
    
                   
  4. Implement finalizeSummaries() , in order to modify what is displayed on the summary pane, if necessary.

    The method is passed a Map object with key-value pairs that are displayed in the summary pane. You can modify existing key-value pairs, or add additional pairs.

    The following sample takes a key-value pair from the data model ( Open Mail ) and adds it to the summary Map , and then adds a prefix to an existing key-value pair ( path ) in the summary Map :

                      public void finalizeSummaries(Map summaries, IWizardContext context) {
             
        String openMail = (String) context.getProperty("openMail");
        summaries.put("Open Mail", openMail);
     
        String path = (String) summaries.get("path");
        path = "http://" + path;
        attributes.put("path",path);
    }
    
                   
  5. Implement finalizeDescriptor() , in order to modify the property values that are stored for the object that you are creating with the wizard.

    The method is passed a Map object with key-value pairs that are the property values to be stored for the new object. Add or modify values, as needed.

    At the end of the method, call super.finalizeDescriptor() .

  6. Create a <component> element in the portalapp.xml for the PCM wizard component, similar to the element for a standard component and a standard wizard.

    Add a property element called isStateless in the component-profile element to determine if session data is maintained on the client ( true ) or on the server ( false ).

                      <components>
        <component name="pcmSample">
            <component-config>
                <property name="ClassName" value="pcmWizard"/>
                <property name="SafetyLevel" value="low_safety"/>
            </component-config>
            <component-profile>
                <property name="isStateless" value="true"/>
            </component-profile>
        </component>
    </components>
    
                   

Options

In addition to the above steps, you may also want to do the following:

  • Set UI Strings: Modify the user-interface strings displayed on the panes automatically created by the wizard toolkit, that is, the Info, Summary and Finish panes.

    To modify the strings, implement the setUIStrings() method, which takes a Map object as a parameter. To modify a string, add a key-value pair, indicating the string to modify and the new string.

    The key is a constant in the class of one of the pre-defined wizard toolkit panes.

    The value is a key in a resource bundle that you attach to your PCM wizard component. You can attach a resource bundle to any portal component, as described in Using Resource Bundles .

    For example, to change the question displayed on the Finish pane, add to the Map the following:

    • Key: FinishPane.UIStrings.POST_COMPLETION_CHOICE_CAPTION_BUNDLE_KEY

    • Value: The resource bundle key of the new string

                         protected void setUIStrings(Map map) {
        map.put(FinishPane.UIStrings.POST_COMPLETION_CHOICE_CAPTION_BUNDLE_KEY,
            "NEWSTRING");
    }
    
                      
  • Initialize Wizard for Testing: When the wizard is launched, the wizard toolkit automatically sets initial parameters, such as the location of the new portal object or the portal component on which to base the new portal object.

    During testing, you may run the PCM wizard component as standalone, and now through the administration tools. If so, you need to set some initial parameters, as shown in the following example:

                         public void initWizardSession(IWizardContext context) {
        context.getWizardParameters().put(
            ObjectCreationWizardConstants.SAVE_LOCATION_PARAM,
                "pcd:portal_content/TestObject");
        context.getWizardParameters().put(
            ObjectCreationWizardConstants.TARGET_ID_PARAM,
                "pcd:portal_content/DanielContent/myHelloTemplate");
        context.getWizardParameters().put(
            ObjectCreationWizardConstants.CREATE_MODE_PARAM,
                "com.sapportals.portal.application. Component");
        context.getWizardParameters().put(
            ObjectCreationWizardConstants.OBJECT_TYPE_PARAM,
                "com.sapportals.portal.iview");     
        super.initWizardSession(context);
    }