cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to customize interceptor message while deletion

Former Member
0 Likes
527

There is a remove interceptor in which we are throwing a validator exception like below snippet

throw new MyValidatorException(l10nService.getLocalizedString("exception.itemtype.cannot.remove.online", new Object[] {}));

Property value in localization fiel is : exception.itemtype.cannot.remove.online = can not remove this item type as it has associated online version available.

MyValidatorException class implementation is like below:

public class MyValidatorException extends InterceptorException { public MyValidatorException(final String message) { super(message); this.setCustomErrorMessage(message); } }

This is the implementation and am getting below exception message in backoffice UI while deleting itemtype is like below:

I want below message to be displayed in Backoffie UI as above localized property value

Accepted Solutions (0)

Answers (1)

Answers (1)

ihar
Explorer
0 Likes

Default backoffice notification-area message for remove object failure configurated like:

         <na:notifications eventType="RemoveObject" level="FAILURE">
             <na:message>user.notification.items.unable_to_delete</na:message>
             <!-- Expected map in form object -> exception -->
             <na:references linksEnabled="true">
                 <na:reference placeholder="0"
                               label="#root.size() == 1 ? (@labelService.getObjectLabel(#root.keySet().iterator().next()) + ' ' + @exceptionTranslationService.toString(#root.values().iterator().next())) : #root.size()"
                               message="#root.keySet().iterator().next()" link="#root.size() == 1" />
             </na:references>
         </na:notifications>

In short, your exception message will be mapped to the label user.notification.items.unable_to_delete

Hence the only way to show the custom message is to redeclare the configuration for your needs.

PS: label user.notification.items.unable_to_delete declared in /hybris/bin/ext-backoffice/backoffice/web/webroot/WEB-INF/lib/backoffice-widgets-6.7.0.0-RC8.jar!/backoffice/labels/labels_en.properties

Former Member
0 Likes

Hi ,

 Thanks for the suggestion.

Can you explain me in detail that how to redeclare the configuration to show customized exception message while deleting an items record when it has online version associated to it.