Hi gurus,
How can I throw a cusom error message from the custom listener code, so that it would be displayed on the UI interface for the end user? Thanks.
It is enough to throw a ValidationException
throw ValidationException.getOne(this, CustomerMsg.getMsgObject("Error Msg Here"));
ciao
Mario
From: eLink Entry: Discussion Group - Web Experience Management [mailto:v7webcontentmanagement@elinkkc.opentext.com]Sent: Wednesday, June 11, 2014 4:18 PMTo: eLink RecipientSubject: How to throw a custom error message from listener code to WEM UI?
How to throw a custom error message from listener code to WEM UI?
Posted byvwang@toronto.ca (****, Victor) On 06/11/2014 10:15 AM
[To post a comment, use the normal reply function]
Forum:
Discussion Group - Web Experience Management
Content Server:
Knowledge Center
Hi Mario,
Thanks for the quick reply. However, I don't see the method you mentioned available. The API I see requires a 3rd parameter for VgnException object. I have pastesd the test code below. It currently doesn't display my custom error message. Thanks!
public void consume(AsEvent event) throws ApplicationException,
AuthorizationException, ValidationException {
String causeObj = "";
boolean validate = false;
try {
if (event.getClass() == AsPrePersistenceEvent.class) {
if (event.getType().equals(AsPrePersistenceEvent.PRE_DELETE)) {
validate = true;
}
} catch (Exception e) {
logger.error(CustomerMsg.getMsgObject(e.toString()));
if (validate)
causeObj = validate((AsPrePersistenceEvent) event);
} catch (ValidationException e) {
logger.debug("throw exception to UI.");
throw ValidationException.getOne(causeObj, CustomerMsg.getMsgObject("Can't delete due to references2."), e);
public String validate(AsPrePersistenceEvent event)
throws ValidationException, AuthorizationException, ApplicationException {
String result = "";
boolean throwValidation = false;
ManagedObject mo = null;
logger.debug("entering PreDeleteValidationListener.");
mo = event.getManagedObject();
ManagedObjectVCMRef[] refByObj = ManagedObject.getReferringManagedObjects(mo.getContentManagementId());
if (refByObj.length > 0) {
logger.debug("Object is referred by others.");
throwValidation = true;
result = mo.getName();
e.printStackTrace();
if (throwValidation) {
ValidationException.
throw ValidationException.getOne(result, CustomerMsg.getMsgObject("Can't delete due to references."), "");
logger.debug("exiting PreDeleteValidationListener.");
return result;
Yes, obviously I forgot a param. Use this signature
throw ValidationException.getOne(ASErrorCode.INVALID_STATE, this, CustomerMsg.getMsgObject("My message"));
Said that, your code looks to me rather convoluted. What you want to gather can be obtainbed with the following easier code excerpt
public void consume(AsEvent event) throws ApplicationException, AuthorizationException, ValidationException {
if (event.getClass() == AsPrePersistenceEvent.class && event.getType().equals(AsPrePersistenceEvent.PRE_DELETE)) {
AsPrePersistenceEvent ppEvent = (AsPrePersistenceEvent) event;
ManagedObject mo = ppEvent.getManagedObject();
throw ValidationException.getOne(ASErrorCode.ILLEGAL_ACCESS_ERROR, this, CustomerMsg.getMsgObject("Can't delete due to references."));
Ciao
From: eLink Entry: Discussion Group - Web Experience Management [mailto:v7webcontentmanagement@elinkkc.opentext.com]Sent: Wednesday, June 11, 2014 9:00 PMTo: eLink RecipientSubject: RE How to throw a custom error message from listener code to WEM UI?
RE How to throw a custom error message from listener code to WEM UI?
Posted byvwang@toronto.ca (****, Victor) On 06/11/2014 02:58 PM
publicvoid consume(AsEvent event) throws ApplicationException,
boolean validate =false;
boolean throwValidation =false;
throwValidationException.getOne(result, CustomerMsg.getMsgObject("Can't delete due to references."),"");
Topic:
Thanks Mario.