Step2:Creating an Editor Component

Each editor contains an editor component, whose Java class extendsAbstractEditorComponent, a descendent ofAbstractPortalComponent, making the editor a portal component that can be displayed as an View in the administration pages of the portal.

AbstractEditorComponent implementsIEditorBuilder, which defines only one method,setupEditor(), which is passed anIEditorConfigurationobject. In this method, the editor does the following:

Creates instances of the panes asPaneMetaDataobjects.

Adds the panes to theIEditorConfigurationobject.

Sets the default pane (that is, the pane that is displayed when the editor is launched).

Procedure

Create a new class that extendsAbstractEditorComponent

ImplementsetupEditor(), in which you will create instances of the panes, configure them, and add them to the editor. The following is the method’s signature:

publicvoidsetupEditor(

IEditorConfigurationeditorConfig,

IPortalComponentProfileprofile,

Mapparams,

ResourceBundleeditorTexts){

}

Create instances of the panes for the editor and configure the panes. For each pane, do the following:

Create aPaneMetaDataobject for representing the pane. ThePaneMetaDataconstructor takes theClassobject of your pane class, and a string that is the name of the pane.

PaneMetaDatapersonalDetailsPane=

newPaneMetaData(PersonalDetailsPane.class"Personal Info");

Set the tooltip displayed when hovering over the radio button that displays the pane.

personalDetailsPane.setDescription("personal details information");

Set the server event that causes the pane to be displayed.

personalDetailsPane.setActivatingEvent("personalDetails");

A pane can also be displayed by the user by clicking the pane’s radio button at the top of the editor.

Indicate whether a radio button is displayed for this pane in the pane selection area at the top of the editor.

personalDetailsPane.setPaneSelectionMember(true);

If no radio button is displayed for the pane, the only way to display the pane is via an activating event.

Add each pane to the editor by callingaddEditorPane()on theIEditorConfigurationobject that is passed into thesetupEditor()method.

editorConfig.addEditorPane(personalDetailsPane);

Specify the default pane, that is, the pane that is displayed when the editor is launched.

editorConfig.setDefaultEditorPane(paymentPane);

Create an entry in theportalapp.xmlfor the editor component. The<component>element is similar to a standard component, except that you specify the following in the<component-profile>element:

Data Handler:In thecom.sap.portal.admin.editorframework.dataHandlerproperty, specify the class or service that implements the data handler.

For more information on creating the data handler, see Step 3: Creating a Data Handler and portalapp.xml .

JavaScript Resource:If you are including a JavaScript resource for the editor, specify in thecom.sap.portal.admin.editorframework.jsResourceproperty the path to the JavaScript file.

Generic Events Handler:If you are including a custom generic events handler, specify in thecom.sap.portal.admin.editorframework.eventsHandlerproperty the class that implements the events handler.

For more information on creating custom generic events handlers, see Generic Events .

iView Properties:Specify iView properties in order to properly display the editor. For example, remove the iView tray and set the isolation mode to URL.

The following is an example<component>element for an editor component:

<components>

<componentname="TrainEditor">

<component-config>

<propertyname="ClassName"value="myPackage.TrainEditor"/>

<propertyname="SafetyLevel"value="low_safety"/>

</component-config>

<component-profile>

<propertyname=

"com.sap.portal.admin.editorframework.dataHandler"

value="myEditor.myDataHandler"/>

<propertyname="com.sap.portal.iview.ShowTray"value="false"/>

<propertyname="com.sap.portal.reserved.iview.IsolationMode"

value="URL"/>

<propertyname="com.sap.portal.iview.HeightType"

value="FULL_PAGE"/>

<propertyname="isStateless"value="false"/>

</component-profile>

</component>

</components>

Result

The following is an example ofsetupEditor()for creating and configuring two panes:

publicvoidsetupEditor(

IEditorConfigurationeditorConfig,

IPortalComponentProfileprofile,

Mapparams,

ResourceBundleeditorTexts){

//Create and configure personal info pane.

PaneMetaDatapersonalDetailsPane=

newPaneMetaData(PersonalDetailsPane.class"Personal Info");

personalDetailsPane.setDescription("personal details information");

personalDetailsPane.setActivatingEvent("personalDetails");

personalDetailsPane.setPaneSelectionMember(true);

//Create and configure the payment info pane.

PaneMetaDatapaymentPane=

newPaneMetaData(PaymentPane.class"Payment Info");

paymentPane.setPaneSelectionMember(true);

paymentPane.setActivatingEvent("paymentPane");

//Add panes to the editor.

editorConfig.addEditorPane(personalDetailsPane);

editorConfig.addEditorPane(paymentPane);

//Set default pane.

editorConfig.setDefaultEditorPane(PersonalDetailsPane.class);

}