1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
<%@ page import="org.apache.struts.action.*, org.apache.struts.Globals" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<html:html>
<head>
<title>Test Error and Message Tags</title><%
ActionErrors errors = new ActionErrors();
errors.add("property1", new ActionError("property1error1"));
errors.add("property2", new ActionError("property2error1"));
errors.add("property2", new ActionError("property2error2"));
errors.add("property2", new ActionError("property2error3"));
errors.add("property3", new ActionError("property3error1"));
errors.add("property3", new ActionError("property3error2"));
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("globalError"));
request.setAttribute(Globals.ERROR_KEY, errors);
ActionMessages messages = new ActionMessages();
messages.add("property1", new ActionMessage("property1message1"));
messages.add("property2", new ActionMessage("property2message1"));
messages.add("property2", new ActionMessage("property2message2"));
messages.add("property2", new ActionMessage("property2message3"));
messages.add("property3", new ActionMessage("property3message1"));
messages.add("property3", new ActionMessage("property3message2"));
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("globalMessage"));
request.setAttribute(Globals.MESSAGE_KEY, messages);
%>
</head>
<body bgcolor="white">
<div align="center">
<h1>Test Error and Message Tags</h1>
</div>
<h3>ERRORS Tag</h3>
<table border="1">
<tr>
<th>Test Type</th>
<th>Correct Value</th>
<th>Test Result</th>
</tr>
<tr>
<td>Errors for Property 1</td>
<td>
<table>
<tr>
<td>Property 1, Error 1</td>
</tr>
</table>
</td>
<td>
<html:errors property="property1" />
</td>
</tr>
<tr>
<td>Errors for Property 2</td>
<td>
<table>
<tr>
<td>Property 2, Error 1</td>
</tr>
<tr>
<td>Property 2, Error 2</td>
</tr>
<tr>
<td>Property 2, Error 3</td>
</tr>
</table>
</td>
<td>
<html:errors property="property2" />
</td>
</tr>
<tr>
<td>All Errors</td>
<td>
<table>
<tr>
<td>Property 1, Error 1</td>
</tr>
<tr>
<td>Property 2, Error 1</td>
</tr>
<tr>
<td>Property 2, Error 2</td>
</tr>
<tr>
<td>Property 2, Error 3</td>
</tr>
<tr>
<td>Property 3, Error 1</td>
</tr>
<tr>
<td>Property 3, Error 2</td>
</tr>
<tr>
<td>Global Error</td>
</tr>
</table>
</td>
<td>
<html:errors />
</td>
</tr>
</table>
<h3>MESSAGES Tag</h3>
<table border="1">
<tr>
<th>Test Type</th>
<th>Correct Value</th>
<th>Test Result</th>
</tr>
<tr>
<td>Messages for Property 1</td>
<td>
<table>
<tr>
<td>Property 1, Message 1</td>
</tr>
</table>
</td>
<td>
<html:messages property="property1" message="true" id="msg" header="messages.header" footer="messages.footer">
<tr>
<td>
<%= pageContext.getAttribute("msg") %>
</td>
</tr>
</html:messages>
</td>
</tr>
<tr>
<td>Messages for Property 2</td>
<td>
<table>
<tr>
<td>Property 2, Message 1</td>
</tr>
<tr>
<td>Property 2, Message 2</td>
</tr>
<tr>
<td>Property 2, Message 3</td>
</tr>
</table>
</td>
<td>
<html:messages property="property2" message="true" id="msg" header="messages.header" footer="messages.footer">
<tr>
<td>
<%= pageContext.getAttribute("msg") %>
</td>
</tr>
</html:messages>
</td>
</tr>
<tr>
<td>All Messages</td>
<td>
<table>
<tr>
<td>Property 1, Message 1</td>
</tr>
<tr>
<td>Property 2, Message 1</td>
</tr>
<tr>
<td>Property 2, Message 2</td>
</tr>
<tr>
<td>Property 2, Message 3</td>
</tr>
<tr>
<td>Property 3, Message 1</td>
</tr>
<tr>
<td>Property 3, Message 2</td>
</tr>
<tr>
<td>Global Message</td>
</tr>
</table>
</td>
<td>
<html:messages message="true" id="msg" header="messages.header" footer="messages.footer">
<tr>
<td>
<%= pageContext.getAttribute("msg") %>
</td>
</tr>
</html:messages>
</td>
</tr>
</table>
</body>
</html:html>
|