struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject svn commit: r751829 - in /struts/sandbox/trunk/s2-jquery-showcase/src: main/webapp/WEB-INF/content/simple-theme/ test/resources/selenium/
Date Mon, 09 Mar 2009 20:59:33 GMT
Author: wesw
Date: Mon Mar  9 20:59:33 2009
New Revision: 751829

URL: http://svn.apache.org/viewvc?rev=751829&view=rev
Log:
finishing up with simple theme

Added:
    struts/sandbox/trunk/s2-jquery-showcase/src/test/resources/selenium/FormWithResetGetReqAjaxRespSimpleTheme
Modified:
    struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/FormWithResetPostReqAjaxResp-input.jsp
    struts/sandbox/trunk/s2-jquery-showcase/src/test/resources/selenium/s2-jquery-plugin-selenium-tests

Modified: struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/FormWithResetPostReqAjaxResp-input.jsp
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/FormWithResetPostReqAjaxResp-input.jsp?rev=751829&r1=751828&r2=751829&view=diff
==============================================================================
--- struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/FormWithResetPostReqAjaxResp-input.jsp
(original)
+++ struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/FormWithResetPostReqAjaxResp-input.jsp
Mon Mar  9 20:59:33 2009
@@ -5,20 +5,49 @@
 <title>Hello World!</title>
 <sjx:head />
     <script type="text/javascript">
-        function handleAjaxResponse(data, textStatus) {
-            $("#messages").append(data + "<br />\n");
+        function handleAjaxResponse(responseText, textStatus) {
+
+            //clear previous validation errors, if any
+            $("#errors").empty();
+
+            //get errors from response
+            var errorsObject = StrutsJQueryUtils.getValidationErrors(responseText);
+
+            //show errors, if any
+            if (errorsObject && errorsObject.fieldErrors) {
+                for (var fieldName in errorsObject.fieldErrors) {
+                    for (var i = 0; i < errorsObject.fieldErrors[fieldName].length; i++)
{
+                        $("#errors").html(
+                             $("#errors").html() + "<br/>" + errorsObject.fieldErrors[fieldName][i]
+                                );
+                    }
+                }
+            }
+            else {
+                var formData = StrutsJQueryUtils.keyValueizeForm("indexForm");
+                formData["struts.enableJSONValidation"] = false;
+                $.post("/s2-jquery-showcase/simple-theme/SimpleFormPostAjaxResponse", formData,
handleFormCb);
+            }
+        }
+
+        function handleFormCb(responseText, textStatus) {
+            $("#messages").append(responseText + "<br />\n");
         }
     </script>
 </head>
 <body>
 <sjx:form theme="jquery-simple" id="indexForm" method="post" validate="true"
-          namespace="/form"
-          action="FormWithResetPostReqAjaxResp"
+          namespace="/form" action="FormWithResetPostReqAjaxResp"
           ajaxResult="true" ajaxResultHandler="handleAjaxResponse" >
+
+    <input type="hidden" id="struts.enableJSONValidation" name="struts.enableJSONValidation"
value="true" />
+    
 <sjx:textfield key="msg" />
 <sjx:submit />
-<sjx:reset />
+<%-- TODO what is the point of a reset button in an AJAX form if you don't use onreset=
? --%>
+<sjx:reset onclick="$('#errors').empty();" />
 </sjx:form>
 <div id="messages"></div>
+<div id="errors" style="color:red"></div>
 </body>
 </html>

Added: struts/sandbox/trunk/s2-jquery-showcase/src/test/resources/selenium/FormWithResetGetReqAjaxRespSimpleTheme
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/s2-jquery-showcase/src/test/resources/selenium/FormWithResetGetReqAjaxRespSimpleTheme?rev=751829&view=auto
==============================================================================
--- struts/sandbox/trunk/s2-jquery-showcase/src/test/resources/selenium/FormWithResetGetReqAjaxRespSimpleTheme
(added)
+++ struts/sandbox/trunk/s2-jquery-showcase/src/test/resources/selenium/FormWithResetGetReqAjaxRespSimpleTheme
Mon Mar  9 20:59:33 2009
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>FormWithResetGetReqAjaxRespSimpleTheme</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">FormWithResetGetReqAjaxRespSimpleTheme</td></tr>
+</thead><tbody>
+<tr>
+	<td>open</td>
+	<td>/s2-jquery-showcase/simple-theme/FormWithResetPostReqAjaxResp-input</td>
+	<td></td>
+</tr>
+<tr>
+	<td>click</td>
+	<td>indexForm_0</td>
+	<td></td>
+</tr>
+<tr>
+	<td>pause</td>
+	<td>500</td>
+	<td></td>
+</tr>
+<tr>
+	<td>verifyTextPresent</td>
+	<td>You must enter a message.</td>
+	<td></td>
+</tr>
+<tr>
+	<td>type</td>
+	<td>indexForm_msg</td>
+	<td>a message</td>
+</tr>
+<tr>
+	<td>click</td>
+	<td>indexForm_0</td>
+	<td></td>
+</tr>
+<tr>
+	<td>pause</td>
+	<td>500</td>
+	<td></td>
+</tr>
+<tr>
+	<td>verifyTextPresent</td>
+	<td>a message</td>
+	<td></td>
+</tr>
+<tr>
+	<td>click</td>
+	<td>//input[@value='Reset']</td>
+	<td></td>
+</tr>
+<tr>
+	<td>pause</td>
+	<td>500</td>
+	<td></td>
+</tr>
+<tr>
+	<td>verifyTextNotPresent</td>
+	<td>You must enter a message</td>
+	<td></td>
+</tr>
+<tr>
+	<td>type</td>
+	<td>indexForm_msg</td>
+	<td>another message</td>
+</tr>
+<tr>
+	<td>click</td>
+	<td>indexForm_0</td>
+	<td></td>
+</tr>
+<tr>
+	<td>pause</td>
+	<td>500</td>
+	<td></td>
+</tr>
+<tr>
+	<td>verifyTextPresent</td>
+	<td>another message</td>
+	<td></td>
+</tr>
+<tr>
+	<td>click</td>
+	<td>//input[@value='Reset']</td>
+	<td></td>
+</tr>
+<tr>
+	<td>click</td>
+	<td>indexForm_0</td>
+	<td></td>
+</tr>
+<tr>
+	<td>pause</td>
+	<td>500</td>
+	<td></td>
+</tr>
+<tr>
+	<td>verifyTextPresent</td>
+	<td>You must enter a message.</td>
+	<td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>

Modified: struts/sandbox/trunk/s2-jquery-showcase/src/test/resources/selenium/s2-jquery-plugin-selenium-tests
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/s2-jquery-showcase/src/test/resources/selenium/s2-jquery-plugin-selenium-tests?rev=751829&r1=751828&r2=751829&view=diff
==============================================================================
--- struts/sandbox/trunk/s2-jquery-showcase/src/test/resources/selenium/s2-jquery-plugin-selenium-tests
(original)
+++ struts/sandbox/trunk/s2-jquery-showcase/src/test/resources/selenium/s2-jquery-plugin-selenium-tests
Mon Mar  9 20:59:33 2009
@@ -14,6 +14,9 @@
 <tr><td><a href="SimpleFormGetAjaxResponse">SimpleFormGetAjaxResponse</a></td></tr>
 <tr><td><a href="FormWithResetGetReqAjaxResp">FormWithResetGetReqAjaxResp</a></td></tr>
 <tr><td><a href="FormWithResetPostReqAjaxResp">FormWithResetPostReqAjaxResp</a></td></tr>
+<tr><td><a href="FormPostNonAjaxResponseSimpleTheme">FormPostNonAjaxResponseSimpleTheme</a></td></tr>
+<tr><td><a href="FormPostAjaxResponseSimpleTheme">FormPostAjaxResponseSimpleTheme</a></td></tr>
+<tr><td><a href="FormWithResetGetReqAjaxRespSimpleTheme">FormWithResetGetReqAjaxRespSimpleTheme</a></td></tr>
 </tbody></table>
 </body>
 </html>



Mime
View raw message