Show TOC

Programming User MessagesLocate this document in the navigation structure

Prerequisites

You have created:

Context

User Messages are messages that are displayed on the mobile device depending on the user action performed.

Procedure

  1. Double-click the Message Pool node.

    Alternatively, press F3 , or, in the Message Pool context menu, choose Open .

  2. In the Resource Text tab page, click Add to add a new resource.
  3. In the New Resource dialog window, choose errorMessage as the Resource Type .
  4. Enter a Resource Name .

    Use an ID for the exception, such as I nvalid E mployee N ame Exception .

  5. Enter a Text .

    Use a text targeted for the user, such as Employee Name is not valid !

    The created resource appears in the table of the *<<Service Component>>.xlf tab page.

  6. Save your data.
    Note

    By using the message pool, you can ensure internationalization of your application.

  7. Create an instance of the exception in the custom operation.

    More information: Start of the navigation path http://help.sap.com/javadocs Next navigation step Mobile 7.1 Next navigation step Mobile Applications for Handhelds Next navigation step com.sap.tc.mobile.wdlite.ocaexceptions Next navigation step OCAException End of the navigation path

  8. Provide logging and user notification details in the controller implementation of the UI Component.

    More information:

    • Start of the navigation path http://help.sap.com/javadocs Next navigation step Mobile 7.1 Next navigation step Mobile Applications for Handhelds Next navigation step com.sap.tc.mobile.wdlite.ocaexceptions Next navigation step IOCAException End of the navigation path

    • Start of the navigation path http://help.sap.com/javadocs Next navigation step Mobile 7.1 Next navigation step Mobile Applications for Handhelds Next navigation step com.sap.tc.mobile.wdlite.ocaexceptions Next navigation step IOCAExceptionHandler End of the navigation path

Example

Creating an Instance of the Exception
            //Creating an instance for the exception InvalidEmployeeNameException and display the message on the mobile device
//@@begin implementation
        if ((arg0.getName() == null) || (arg0.getName().length() == 0)) {
                throw new InvalidEmployeeNameException("INVALID_EMPLOYEE_NAME_ID",
                        WDLite.getApplicationDCName(),
                        new String[] {"null"}, IOCAException.ERROR);
        } 
//@@end

         
Logging and Raising Exception Messages
            //Use the Exception Handler class to log and raise the exception message 
public void saveNewEmployee() {
//@@begin saveNewEmployee()
                        try {
                                EmployeeSdoEmployee arg0 = (EmployeeSdoEmployee) wdContext
                                                        .nodeNewEmployee().getCurrentElement().model();
                                service.checkEmployee(arg0);
                                root.commit();
                                refreshEmployeeList();
                        } catch (InvalidEmployeeNameException e) {
                                // To be displayed on CFS RT Container UI 
                                WDLite.getExceptionHandler().logAndRaiseMessage(e);
                        }