On Java Development

All things related to Java development, from the perspective of a caveman.

Properly Displaying Messages Using an Error Message Dialog

without comments


This post illustrates the use of the error message dialog that is contained in baseproject. It is designed to be displayed when exceptions occur during processing.

Consider the following dialog that asks the user if they want to proceed with a requested process, such as approving claim checks.

The code for the dialog is shown below.

Take note of the entry on line 21, specifically this; id-errorMessageDialog Without it, if there are errors that occured during processing, the error message dialog will be displayed as shown below.

However, with it, the dialog is shown with the error messages as expected.

The #{rich:clientId(‘id-errorMessageDialog’) ensures the dialog is properly rendered with the messages.

This is the code for the error message dialog. Note line 4 that has identified the component as “id-errorMessageDialog”


Setting the error

The first question here is; “Do I evoke the error in the Service or the DAO?” The answer lies in understanding the different responsibilities of the Service vs the DAO. Simply stated, the DAO should not contain business logic. It’s role is to only gather or persist data. It propagates I/O related errors back up to the Service layer where the service can add additional messages if required. The Service is where the business logic exists and is where rules are applied. So, the answer is “In the service.”

For another example of error messages and dialogs for the UI, see Using Exceptions to Create UI Messages.

Written by admin

March 31st, 2014 at 4:57 am

Leave a Reply

You must be logged in to post a comment.