ATG Portal includes a class named atg.portal.admin.I18nMessageProcessor that is useful for handling messages generated by pages. The I18nMessageProcessor collects the messages generated. It can then use the page’s request to determine the locale and the resource bundle to generate the appropriate localized message.

ATG Portal includes two I18nMessageProcessor components, named /atg/portal/admin/FailureMessageProcessor and /atg/portal/admin/SuccessMessageProcessor. These components are identical except in name; using two of them lets you handle and render success and failure messages separately. Configure your form handler to use these two I18nMessageProcessor components by setting these two properties, which exist in classes that extend I18nFormHandler or PortalGenericFormHandler:

failureMessageProcessor=/atg/portal/admin/FailureMessageProcessor
successMessageProcessor=/atg/portal/admin/SuccessMessageProcessor

The I18nMessageProcessor has a localizeMessages method. This method takes any pending messages in the I18nMessageProcessor and formats them, based on the locale of the request passed to the localizeMessages method. You can then extract the localized messages and output them.

Using a centralized message processor allows you to redirect between pages indiscriminately and not have to worry that messages might get lost. With message processors in no case will they get lost, although they may get deferred if you redirect to a page that doesn’t contain message rendering code. In that case the messages will be rendered the next time the user reaches a page that does have rendering code.

 
loading table of contents...