سؤال

I can display errors for specific fields using this tag:

<s:fielderror fieldName="myField" />

But in addition to displaying the error message I would like to highlight the field in red. To do this I need to know if a field generated an error, and then add error class to this field.

How can I check if specific field has generated an error?

هل كانت مفيدة؟

المحلول

Errors for fields are stored in fieldErrors map. So you can check for specific field error in <s:if> tag like that

<s:if test="fieldErrors.containsKey('fieldName')">
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top