Is it possible to get label of any text field inside any interceptor?

313 Views Asked by At

I have made a custom interceptor to display the error messages in my own format. It is successful to an extent.

But i would like to know can we get label of any textfield directly from invocation object?

Thanks in advance

1

There are 1 best solutions below

1
Steven Benitez On

If your field labels are localized, then yes, you can get the label text. Otherwise, no, since they would just be a string literal in the JSP.

Assuming you have a localized property: field.firstName = First Name

You can get that from your interceptor using:

LocalizedTextUtil.findDefaultText(
    "field.firstName", 
    invocation.getInvocationContext().getLocale()
);

However, if you provide more details on what you are trying to do, we may be able to offer better solutions.