Author: wesw
Date: Mon Mar  9 18:25:49 2009
New Revision: 751786

URL: http://svn.apache.org/viewvc?rev=751786&view=rev
Log:
adding simple theme to showcase

Added:
    
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/
    
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/FormWithResetPostReqAjaxResp-input.jsp
      - copied, changed from r750605, 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/FormWithResetPostReqAjaxResp-input.jsp
    
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/FormWithResetPostReqAjaxResp.jsp
      - copied unchanged from r750605, 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/FormWithResetPostReqAjaxResp.jsp
    
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/SimpleFormPostAjaxResponse-input.jsp
      - copied, changed from r750456, 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/SimpleFormPostAjaxResponse-input.jsp
    
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/SimpleFormPostAjaxResponse.jsp
      - copied unchanged from r750456, 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/SimpleFormPostAjaxResponse.jsp
    
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/SimpleFormPostNonAjaxResponse-input.jsp
      - copied, changed from r750456, 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/SimpleFormPostNonAjaxResponse-input.jsp
    
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/SimpleFormPostNonAjaxResponse.jsp
      - copied unchanged from r750456, 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/SimpleFormPostNonAjaxResponse.jsp
Modified:
    
struts/sandbox/trunk/s2-jquery-showcase/src/main/java/org/apache/struts2/jquery/actions/form/MessageAction.java

Modified: 
struts/sandbox/trunk/s2-jquery-showcase/src/main/java/org/apache/struts2/jquery/actions/form/MessageAction.java
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/s2-jquery-showcase/src/main/java/org/apache/struts2/jquery/actions/form/MessageAction.java?rev=751786&r1=751785&r2=751786&view=diff
==============================================================================
--- 
struts/sandbox/trunk/s2-jquery-showcase/src/main/java/org/apache/struts2/jquery/actions/form/MessageAction.java
 (original)
+++ 
struts/sandbox/trunk/s2-jquery-showcase/src/main/java/org/apache/struts2/jquery/actions/form/MessageAction.java
 Mon Mar  9 18:25:49 2009
@@ -15,6 +15,9 @@
     private String msg;
 
     @Actions({
+            @Action("/simple-theme/SimpleFormPostAjaxResponse"),
+            @Action("/simple-theme/SimpleFormPostNonAjaxResponse"),
+            @Action("/simple-theme/FormWithResetPostReqAjaxResp"),
             @Action("SimpleFormGetAjaxResponse"),
             @Action("SimpleFormPostAjaxResponse"),
             @Action("SimpleFormGetNonAjaxResponse"),

Copied: 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/FormWithResetPostReqAjaxResp-input.jsp
 (from r750605, 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/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?p2=struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/FormWithResetPostReqAjaxResp-input.jsp&p1=struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/FormWithResetPostReqAjaxResp-input.jsp&r1=750605&r2=751786&rev=751786&view=diff
==============================================================================
--- 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/FormWithResetPostReqAjaxResp-input.jsp
 (original)
+++ 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/FormWithResetPostReqAjaxResp-input.jsp
 Mon Mar  9 18:25:49 2009
@@ -11,7 +11,7 @@
     </script>
 </head>
 <body>
-<sjx:form id="indexForm" method="post" validate="true"
+<sjx:form theme="jquery-simple" id="indexForm" method="post" validate="true"
           namespace="/form"
           action="FormWithResetPostReqAjaxResp"
           ajaxResult="true" ajaxResultHandler="handleAjaxResponse" >

Copied: 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/SimpleFormPostAjaxResponse-input.jsp
 (from r750456, 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/SimpleFormPostAjaxResponse-input.jsp)
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/SimpleFormPostAjaxResponse-input.jsp?p2=struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/SimpleFormPostAjaxResponse-input.jsp&p1=struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/SimpleFormPostAjaxResponse-input.jsp&r1=750456&r2=751786&rev=751786&view=diff
==============================================================================
--- 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/SimpleFormPostAjaxResponse-input.jsp
 (original)
+++ 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/SimpleFormPostAjaxResponse-input.jsp
 Mon Mar  9 18:25:49 2009
@@ -11,13 +11,13 @@
     </script>
 </head>
 <body>
-<sjx:form id="indexForm" method="post" validate="true"
-          namespace="/form"
-          action="SimpleFormPostAjaxResponse"
+<sjx:form theme="jquery-simple" id="indexForm" method="post" validate="true"
+          namespace="/form" action="SimpleFormPostAjaxResponse"
           ajaxResult="true" ajaxResultHandler="handleAjaxResponse" >
 <sjx:textfield key="msg" />
 <sjx:submit />
 </sjx:form>
 <div id="messages"></div>
+<div id="errors" style="color:red"></div>
 </body>
 </html>

Copied: 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/SimpleFormPostNonAjaxResponse-input.jsp
 (from r750456, 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/SimpleFormPostNonAjaxResponse-input.jsp)
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/SimpleFormPostNonAjaxResponse-input.jsp?p2=struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/SimpleFormPostNonAjaxResponse-input.jsp&p1=struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/SimpleFormPostNonAjaxResponse-input.jsp&r1=750456&r2=751786&rev=751786&view=diff
==============================================================================
--- 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/form/SimpleFormPostNonAjaxResponse-input.jsp
 (original)
+++ 
struts/sandbox/trunk/s2-jquery-showcase/src/main/webapp/WEB-INF/content/simple-theme/SimpleFormPostNonAjaxResponse-input.jsp
 Mon Mar  9 18:25:49 2009
@@ -2,15 +2,59 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd";>
 <html>
 <head>
-<title>Hello World!</title>
-<sjx:head />
+    <title>Hello World!</title>
+    <script type="text/javascript">
+        function handleForm_indexForm() {
+            var formData = StrutsJQueryUtils.keyValueizeForm("indexForm");
+            formData['struts.enableJSONValidation'] = true;
+            $.post("/s2-jquery-showcase/form/SimpleFormPostNonAjaxResponse", 
formData, handleFormCb_indexForm);
+            return false;
+        }
+
+        function handleFormCb_indexForm(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 form = document.getElementById("indexForm");
+                form.submit();
+            }
+        }
+    </script>
+    <sjx:head/>
 </head>
 <body>
-<sjx:form id="indexForm" method="post" validate="true"
+<!-- TODO on sjx:form validate="true" will call handleForm_${formId} as a 
callback -->
+
+<sjx:form theme="jquery-simple" id="indexForm" method="post" validate="true"
           action="SimpleFormPostNonAjaxResponse"
-          ajaxResult="false" >
-<sjx:textfield key="msg" />
-<sjx:submit />
+          ajaxResult="false">
+<table>
+    <tr>
+        <td align="right">Message</td>
+    </tr>
+    <tr>
+        <td><sjx:textfield key="msg"/></td>
+    </tr>
+    <tr>
+        <td colspan="2" align="center"><sjx:submit/></td>
+    </tr>
+</table>
 </sjx:form>
+<div id="errors" style="color:red"></div>
 </body>
 </html>


Reply via email to