martinc 2002/07/15 21:56:42
Modified: src/exercise-taglib/org/apache/struts/webapp/exercise
ApplicationResources.properties
web/exercise-taglib index.jsp
web/exercise-taglib/WEB-INF struts-config.xml
Added: web/exercise-taglib html-messages.jsp
Log:
Added test cases for <html:errors> and <html:messages> tags.
Revision Changes Path
1.2 +31 -0
jakarta-struts/src/exercise-taglib/org/apache/struts/webapp/exercise/ApplicationResources.properties
Index: ApplicationResources.properties
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/exercise-taglib/org/apache/struts/webapp/exercise/ApplicationResources.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ApplicationResources.properties 13 Jan 2002 00:25:35 -0000 1.1
+++ ApplicationResources.properties 16 Jul 2002 04:56:42 -0000 1.2
@@ -0,0 +1,31 @@
+#
+# Resources for testing <html:errors> tag.
+#
+
+errors.header=<table>
+errors.footer=</table>
+errors.prefix=<tr><td>
+errors.suffix=</td></tr>
+
+property1error1=Property 1, Error 1
+property2error1=Property 2, Error 1
+property2error2=Property 2, Error 2
+property2error3=Property 2, Error 3
+property3error1=Property 3, Error 1
+property3error2=Property 3, Error 2
+globalError=Global Error
+
+#
+# Resources for testing <html:messages> tag.
+#
+
+messages.header=<table>
+messages.footer=</table>
+
+property1message1=Property 1, Message 1
+property2message1=Property 2, Message 1
+property2message2=Property 2, Message 2
+property2message3=Property 2, Message 3
+property3message1=Property 3, Message 1
+property3message2=Property 3, Message 2
+globalMessage=Global Message
1.4 +1 -0 jakarta-struts/web/exercise-taglib/index.jsp
Index: index.jsp
===================================================================
RCS file: /home/cvs/jakarta-struts/web/exercise-taglib/index.jsp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- index.jsp 8 Jul 2001 04:15:14 -0000 1.3
+++ index.jsp 16 Jul 2002 04:56:42 -0000 1.4
@@ -26,6 +26,7 @@
<li><a href="html-multibox.jsp"><html:multibox></a></li>
<li><a href="html-select.jsp"><html:select></a></li>
<li><a href="html-setters.jsp">Scalar Setters</a></li>
+<li><a href="html-messages.jsp">Errors and Messages</a></li>
</ul>
<h3>LOGIC Tags</h3>
1.1 jakarta-struts/web/exercise-taglib/html-messages.jsp
Index: html-messages.jsp
===================================================================
<%@ page language="java" import="org.apache.struts.action.*" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="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(Action.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(Action.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>
1.6 +4 -0 jakarta-struts/web/exercise-taglib/WEB-INF/struts-config.xml
Index: struts-config.xml
===================================================================
RCS file: /home/cvs/jakarta-struts/web/exercise-taglib/WEB-INF/struts-config.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- struts-config.xml 25 Jun 2001 00:02:32 -0000 1.5
+++ struts-config.xml 16 Jul 2002 04:56:42 -0000 1.6
@@ -50,4 +50,8 @@
</action>
</action-mappings>
+ <message-resources
+ parameter="org.apache.struts.webapp.exercise.ApplicationResources"
+ null="false" />
+
</struts-config>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>