Implement messages
This section describes how error, warning, and question messages are created.
Â
What does this section cover?
Error Messages
In order for an error message to appear on screen, a java exception must be created and thrown.Â
- Create the Exception class.Â
- All exception classes must extend com.crm.exception.CRMValidationException.Â
- All exception methods should have a com.crm.exception.CRMValidationException object as an input parameter and use setMessage method of com.crm.exception.CRMException class.
- To create the exception method:
- Use com.crm.businessobject.CRMSession object as an input parameter and any other String input parameters needed.
- Put all String input parameters in a String ArrayList.
- Use setMessage method of com.crm.exception.CRMException class to construct the exception message.
- To create the exception method:
   2. Define the exception in the messages.xml file. Use a unique key for the expression tag. For more information on customising messages metadata, go to Customize Messages Metadata.
   3. Define the exception in English translation properties file, by using the expression tag key defined in metadata messages file as the entry key, and specifying the exception message. Use %<number> where the input parameters should be placed. Note that <number> is their index+1 in parameters array list.
   4. Throw the exception.
Question Messages
In order for a question message to appear on screen, two java methods should be created.
- Create the java method that will display the question.
- Use showConfirmQuestion method of com.crm.process.CRMUI class to display the confirmation question.Â
- Define the method to be called if the user clicks 'YES' (class name, method name, question code) and message parameters, as input parameters for showConfirmQuestion method.
- Continue implementing what should be executed right after postPayment method, if the user clicks 'YES', or right after the user clicks 'NO'.
- Use showConfirmQuestion method of com.crm.process.CRMUI class to display the confirmation question.Â
- Create the java method that will be called if the user clicks 'YES'
   3. Define the question code in metadata messages file.
   4. Define the question in the English translation properties file, by using the expression tag key defined in metadata messages file as the entry key, and specifying the question message. Use %<number> where the message parameters should be placed. Note that <number> is their index+1 in message parameters array list.
Informational Messages
In order for n informational message to appear on screen, you have toÂ
- Create an instance of com.crm.process.InfoMessage object, defining the session, message code, message parameters, session real path, and organisation id as shown below.
- Use showInfoMessage method of com.crm.process.CRMUI class to display the message on screen.
   3. Define the message code in metadata messages file.
   4. Define the message in the English translation properties file, by using the expression tag key defined in metadata messages file as the entry key, and specifying the question message. Use %<number> where the message parameters should be placed. Note that <number> is their index+1 in message parameters array list.