Question:- Can you explain about ActionErrors, ActionMessage, ActionError class?
- ActionErrors class object represents all form validation errors of form page in the form of multiple elements. This is a Map Data structure and each element represents one form validation error. In this each element key & values will be there where key represents logical name of form validation error and value represent ActionMessage/ActionError class object having form validation error message.
- From struts 1.3 on wards the ActionError class is removed. So you can work with ActionMessage class as alternate.
ActionErrors class obj (it is like map data structure)
Unerr –> Keys | New ActionMessage/ActionError(“my.un.req.err”);–> Values |
unerr | New ActionMessage/ActionError(“my.un.alpha.err”); |
pwderr | New ActionMessage/ActionError(“my.pass.req.err”); |
pwderr | New ActionMessage/ActionError(“my.pass.alpha.err”); |
- Logical name of one form validation error
- key-represents error message in properties file
- When multiple form validations are there a single bean property then it is recommended to give same logical name for all those form validation errors.
- To apply styles and efforts on form validation error messages add the following keys (fixed) based message in properties file.
In myfile.properties :-
# to apply styles on form validation error messages.
Errors.header = <ul> <font color = red size 2>
Errors.footer = </font></url>
Errors.prefix = <li>
Errors.suffix = </il>
Note: – The above keys based style will not be applied on presentation logic labels of jsp.
- The style of “errors.header” key comes only for one time at the beginning of all the error messages. Lly “errors.footer” based style will come at the end of all the error messages.
- “errors.prefix” styles will come at beginning of each error message. Where as “errors.suffix” styles will come at the end of each message.