Note: For more information about ErrorsTag and MessagesTag, see the Apache Struts documentation. This function is used as is from the original Struts HTML tag library.
There are a variety of ways to use these tags in the JSPs to display errors and messages. One commonly-used way is to add the following to the beginning of the JSP:
When using these tags, remember that in XDIME all text elements must be present in a pane that is within a canvas. To use this tag properly in this way, therefore you must ensure that there a canvas and pane are defined to which the error messages can be written. One way to do this is illustrated in the Mobile Struts Sample portlet provided. For the sample portlet, properties were created in the ApplicationResources.properties
message file. If defined, the errors tag uses the following properties from the configured properties file:
For the Mobile Struts Sample portlet, the ApplicationResources.properties
file contains the following:
errors.header=<canvas layoutName="/Error.mlyt" type="portlet"><pane name="error"><h3>Validation Error!</h3><p>You must correct the following error(s) before proceeding:</p><ul>
errors.prefix = <li>
errors.suffix = </li>
If no errors exist, the canvas and pane are not added, and no messages are displayed. If errors are present, the header is added once, each error is surrounded by prefix and suffix values, and the footer is added once. All of the errors are presented at the beginning of the page and formatted in an unordered list. This requires creating a layout called Error.mlyt
that contains a single pane called error
The example shown here is only one way that these tags can be used. Struts XDIME tags output text, and therefore they must be contained within an XDIME element that supports text.
Parent topic: Struts XDIME design tips