Background documentationWorkProtect Feature Locate this document in the navigation structure

 

If the user enters data in a form and switches to another application or page before saving it, the data is lost. The WorkProtect feature of the EPCF helps to avoid loss of unsaved data in stateful applications. This feature provides tools to maintain the Dirty indicator through which a portal application informs the portal that it has unsaved data.

To benefit from the WorkProtect feature, your portal application needs to set the Dirty indicator when the user enters a value into an input field, and reset it when the user saves the data.

Customizing the WorkProtect Behavior

During the navigation and portal logoff, the EPCF decides where to display the result of the navigation and checks whether there were any reports of unsaved data.

When one or more applications on the page report that they have unsaved data by setting of the Dirty indicator, the whole page is protected from data loss. By default, the navigation target is opened in a new window, while the original window with the unsaved data is left intact.

The portal administrator and the user can customize this behavior in the Service Configuration and Portal Personalization dialogs respectively. It is possible to deactivate the WorkProtect feature completely or display the popup messages so that user can decide how to proceed in each case. For more information, see SAP Note 734861.

In the Portal Personalization dialog, the user can select one of the WorkProtect mode options for handling unsaved data during navigation.

The following figures show popup messages that appear in the most popular browsers:

  • Internet Explorer popup message

    This graphic is explained in the accompanying text.

  • Mozilla Firefox popup message

    This graphic is explained in the accompanying text.

To use the WorkProtect feature, your portal application needs to maintain the Dirty indicator and adjust portal links. You set the Dirty indicator when the user enters a value into an input field, and reset it when the user saves the data.

Reporting Unsaved Data via Event Handlers

You can use client eventing to report unsaved data. The application defines an event handler, which returns a boolean value indicating the presence of unsaved data, and subscribes it to a special namespace and event name as follows:

Syntax Syntax

  1. var isUnsavedData = false;
    if ( application_has_unsaved_data){
        isUnsavedData = true;
    }
    function myHandler (eventObj){
         return isUnsavedData;
    }
    EPCM.subscribeEvent("urn:com.sapportals.portal:workprotect",
                        "inquiryProtection", myHandler);
    
End of the code.
Reporting Unsaved Data via EPCM Method Calls

Alternatively, you can call the EPCM.setDirty method explicitly to set the Dirty indicator:

EPCM.setDirty( true);

However, the application needs to call this method explicitly each time the input data changes.

Adjusting Portal Links

To enable the portal to check the Dirty indicator and perform the navigation without losing data, redirect all links in your application to the appropriate EPCF Navigation API call as follows:

<A HREF=myLink onclick=return EPCM.doNavigate('any_PCD_URL')>

The any_PCD_URL parameter specifies the location of a page or iView in the user role. Constants must be enclosed in quotation marks. You can find the correct value for the page in the Role Editor.

Note Note

Make sure that you update the corresponding parameter values for the PCD_URL in the secondary links and navigation targets when you change the role structure.

End of the note.

More Information

For the complete API reference, see WorkProtect API.