Show TOC

Procedure documentationImplementing iView Modes Locate this document in the navigation structure

 

In WPC, every iView comes with a set of modes that determine how to run the iView in design time. The modes are listed in the options menu of the iView. The following modes are provided by default:

  • Content – runs the content of the iView.

  • Settings – runs a basic property editor of the iView.

Every mode executes a corresponding method. For a mode named Xxx, the corresponding method is named doXxx(). Thus, the methods doContent() and doSettings() are implemented by default. You can override these methods. You can also add new modes, with custom implementations. The new modes are added to the options menu, between the Settings option and the Refresh option. In addition, you can define the default mode to run when the iView is dragged to the page from the Content Templates provider.

To implement an iView mode, you add the mode name to the PortalApp.xml file, and set it as the default mode to run, if relevant. Then, you need to implement a method named do<Name>() in your portal component.

Procedure

  1. In the PortalApp.xml file, under <component-profile>, add the following property: com.sap.portal.apb.custom_run_modes, and enter one or more new mode names, separated by commas.

    For example:

    <property name="com.sap.portal.apb.custom_run_modes" value="Edit, Help"/>

  2. To set the default mode to run when the iView is dragged to the page from Content Templates, use the com.sap.portal.apb.default_run_mode property.

    For example:

    <property name="com.sap.portal.apb.default_run_mode" value="Edit"/>

  3. In your portal component, implement the methods for each mode.

Example

The following example:

  • Shows a PortalApp.xml file with two new iView modes: Edit and Help, where Edit is the default mode to run

  • Provides a class that demonstrates how to implement the doEdit() and doHelp() methods.

PortalApp.xml

Example Example

  1. <application>
      <application-config/>
      <components>
        <component name="IViewModesComponent">
          <component-config>
            <property name="ClassName" value="IViewModesComponent"/>
          </component-config>
          <component-profile>
               <property name="com.sap.portal.apb.default_run_mode" value="Edit"/>
               <property name="com.sap.portal.apb.custom_run_modes" value="Edit, Help"/>
          </component-profile>
        </component>
      </components>
      <services/>
    </application>
    
End of the code.

iViewModesComponent

Example Example

  1. public class IViewModesComponent extends AbstractPortalComponent
    {
        public void doEdit(IPortalComponentRequest request, IPortalComponentResponse response)
        {
          /* Custom implementation of edit mode*/
        }
        public void doHelp(IPortalComponentRequest request, IPortalComponentResponse response)
        {
          /* Custom implementation that displays context-sensitive help */
        }  
    }
    
End of the code.