Programming User Messages
Prerequisites
You have created:
-
A Mobile Service Component
More information: Creating a Mobile Service Component
-
A custom operation, to which you want to add one or more exceptions
More information: Modeling a Custom Operation
-
An Exception
More information: Handling Exceptions
-
A Mobile UI Component
More information: Creating a Mobile UI Component
Context
User Messages are messages that are displayed on the mobile device depending on the user action performed.
Procedure
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);
}

