]> source.dussan.org Git - archiva.git/commitdiff
add in basic validation
authorBrett Porter <brett@apache.org>
Mon, 10 Jul 2006 07:01:58 +0000 (07:01 +0000)
committerBrett Porter <brett@apache.org>
Mon, 10 Jul 2006 07:01:58 +0000 (07:01 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@420447 13f79535-47bb-0310-9956-ffa450edef68

maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/QuickSearchAction.java
maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/QuickSearchAction-validation.xml [new file with mode: 0644]
maven-repository-webapp/src/main/resources/validators.xml [deleted file]
maven-repository-webapp/src/main/resources/xwork.xml
maven-repository-webapp/src/main/webapp/WEB-INF/jsp/quickSearch.jsp
maven-repository-webapp/src/main/webapp/css/site.css

index 78311e99af0a1c73d7f20fe86ac53066980d1317..68fe27b8eca2723e7a7ee82cc12bb40ffc14b382 100644 (file)
@@ -95,10 +95,15 @@ public class QuickSearchAction
         }
         else
         {
-            return ERROR;
+            return INPUT;
         }
     }
 
+    public String doInput()
+    {
+        return SUCCESS;
+    }
+
     public String getQ()
     {
         return q;
diff --git a/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/QuickSearchAction-validation.xml b/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/QuickSearchAction-validation.xml
new file mode 100644 (file)
index 0000000..961cb7c
--- /dev/null
@@ -0,0 +1,26 @@
+<!--
+  ~ Copyright 2005-2006 The Apache Software Foundation.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="q">
+    <field-validator type="requiredstring">
+      <message>You must enter some search terms.</message>
+    </field-validator>
+  </field>
+</validators>
\ No newline at end of file
diff --git a/maven-repository-webapp/src/main/resources/validators.xml b/maven-repository-webapp/src/main/resources/validators.xml
deleted file mode 100644 (file)
index e06880d..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<!--
-  ~ Copyright 2005-2006 The Apache Software Foundation.
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<validators>
-  <validator name="required" class="com.opensymphony.webwork.validators.JavaScriptRequiredFieldValidator"/>
-  <validator name="requiredstring" class="com.opensymphony.webwork.validators.JavaScriptRequiredStringValidator"/>
-  <validator name="int" class="com.opensymphony.webwork.validators.JavaScriptIntRangeFieldValidator"/>
-  <validator name="date" class="com.opensymphony.webwork.validators.JavaScriptDateRangeFieldValidator"/>
-  <validator name="expression" class="com.opensymphony.xwork.validator.validators.ExpressionValidator"/>
-  <validator name="fieldexpression" class="com.opensymphony.xwork.validator.validators.FieldExpressionValidator"/>
-  <validator name="email" class="com.opensymphony.webwork.validators.JavaScriptEmailValidator"/>
-  <validator name="url" class="com.opensymphony.webwork.validators.JavaScriptURLValidator"/>
-  <validator name="visitor" class="com.opensymphony.webwork.validators.JavaScriptVisitorFieldValidator"/>
-  <validator name="conversion" class="com.opensymphony.xwork.validator.validators.ConversionErrorFieldValidator"/>
-  <validator name="stringlength" class="com.opensymphony.xwork.validator.validators.StringLengthFieldValidator"/>
-</validators>
\ No newline at end of file
index 357f08abe38051de7f5bcf5a1d20561a3a8f7d33..813ecda2bfebd7db571a688a226adda634750bf5 100644 (file)
     <!-- Default interceptor stack. -->
     <default-interceptor-ref name="defaultStack"/>
 
-    <action name="index" class="baseAction">
+    <action name="index" class="quickSearchAction" method="input">
       <result name="success" type="dispatcher">/WEB-INF/jsp/quickSearch.jsp</result>
+      <interceptor-ref name="validationWorkflowStack"/>
     </action>
 
     <action name="quickSearch" class="quickSearchAction">
+      <result name="input" type="dispatcher">/WEB-INF/jsp/quickSearch.jsp</result>
       <result name="success" type="dispatcher">/WEB-INF/jsp/results.jsp</result>
-      <result name="error" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
+      <interceptor-ref name="validationWorkflowStack"/>
     </action>
 
-    <!-- TODO! old actions -->
-    <!--
-        <action name="index" class="org.apache.maven.repository.manager.web.action.BaseAction">
-          <result name="success" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
-          <result name="error" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
-        </action>
-    -->
-
+    <!-- TODO! old actions
     <action name="proxy" class="org.apache.maven.repository.proxy.web.action.RepositoryProxyAction">
       <result name="success" type="stream">
         <param name="contentType">application/octet-stream</param>
@@ -77,7 +72,7 @@
       <result name="success" type="dispatcher">/WEB-INF/jsp/indexConfigUpdateSuccess.jsp</result>
       <result name="error" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
     </action>
-
+    -->
   </package>
 </xwork>
 
index b23a7a4c45d66050a10d054e8e677d33900c5923..6b800b9da17560de702048a035890998bb42f21b 100644 (file)
   --%>
 
 <html>
-<head><title>Quick Search</title></head>
+<head>
+  <title>Quick Search</title>
+  <ww:head />
+</head>
 
 <body>
 
@@ -24,8 +27,8 @@
 
 <div id="contentArea">
   <div id="searchBox">
-    <ww:form action="quickSearch.action">
-      <ww:textfield size="50" name="q" />
+    <ww:form method="post" action="quickSearch" validate="true">
+      <ww:textfield label="Search for" size="50" name="q" />
       <ww:submit label="Go!" />
     </ww:form>
     <p>
index 8f0702b3af96522fbc2d0176aeac35c089bcb404..ed9f565799fb3aeb1d580e1b54b370dcf7f5843e 100644 (file)
     font-weight: bold;
 }
 
+/* WebWork validation failures */
+.errorMessage {
+    color: red;
+    font-weight: bold;
+}