title: Trouble with client side validation using Struts 2. Xml based validation rules not recognized
body: <p>My issue is that when I don't see a client side validation error message when I don't enter any values for that field even when it is configured as required. The page is reloaded and goes to the result page and client validation fails. I am not sure what I am doing wrong.</p>
  
  <p>I have a simple form where I have a pull down menu called selection criterion. A value must be selected. If a value is not selected, then the page should reload with configured error message. My input form action_item_search.jsp is given below:</p>
  
  <pre><code>&lt;%@ taglib prefix="s" uri="/struts-tags" %&gt;
      &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
          pageEncoding="ISO-8859-1"%&gt;
      &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
      &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&gt;
      &lt;title&gt;Action Item Search&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;s:actionerror/&gt;
      &lt;s:fielderror /&gt;
      &lt;s:form action="action_item_search" validate="true"&gt;
        &lt;s:select label="Search Criterion" name="searchCriterion"
            list="#{'': 'Select One', 'creatorName':'creator name', 
             assignedTo':'assigned to'}" required="true" /&gt;             
        &lt;s:submit name="search" value="Search"&gt;&lt;/s:submit&gt;
      &lt;/s:form&gt;
      &lt;/body&gt;
  </code></pre>
  
  <p>I have add validators.xml in my WEB-INF/classes directory of exploded war file as given below:</p>
  
  <pre><code>&lt;!DOCTYPE validators PUBLIC
      "-//OpenSymphony Group//XWork Validator Config 1.0//EN"
      "http://www.opensymphony.com/xwork/xwork-validator-config-1.0.dtd"&gt;
   &lt;validators&gt;
  &lt;validator name="required"   
          class="com.opensymphony.xwork2.validator.validators.RequiredFieldValidator"/&gt;
  &lt;validator name="requiredstring" 
          class="com.opensymphony.xwork2.validator.validators.RequiredStringValidator"/&gt;
  &lt;validator name="int" 
          class="com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator"/&gt;
  &lt;validator name="long" 
          class="com.opensymphony.xwork2.validator.validators.LongRangeFieldValidator"/&gt;
  &lt;validator name="short" 
          class="com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator"/&gt;
  &lt;validator name="double" 
         class="com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator"/&gt;
  &lt;validator name="date"  
         class="com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator"/&gt;
  &lt;validator name="expression" 
         class="com.opensymphony.xwork2.validator.validators.ExpressionValidator"/&gt;
  &lt;validator name="fieldexpression" 
         class="com.opensymphony.xwork2.validator.validators.FieldExpressionValidator"/&gt;
  &lt;validator name="email" 
         class="com.opensymphony.xwork2.validator.validators.EmailValidator"/&gt;
  &lt;validator name="url"            
         class="com.opensymphony.xwork2.validator.validators.URLValidator"/&gt;
  &lt;validator name="visitor"           
         class="com.opensymphony.xwork2.validator.validators.VisitorFieldValidator"/&gt;
  &lt;validator name="conversion" 
     class="com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator"/&gt;
  &lt;validator name="stringlength" 
        class="com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator"/&gt;
  &lt;validator name="regex"  
        class="com.opensymphony.xwork2.validator.validators.RegexFieldValidator"/&gt;
  &lt;validator name="conditionalvisitor" 
  class="com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator"/&gt;
  &lt;/validators&gt;
  </code></pre>
  
  <p>ActionItemTrackingAction-findByCriteria-validation.xml in WEB-INF/classes directory is given below:</p>
  
  <pre><code>&lt;!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
     "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"&gt;
  
  &lt;validators&gt;
  &lt;field name="searchCriterion" &gt;
    &lt;field-validator type="required"&gt;
       &lt;message&gt;You must enter a search criterion.&lt;/message&gt;
    &lt;/field-validator&gt;
   &lt;/field&gt;
  &lt;/validators&gt;
  </code></pre>
  
  <p>My struts mapping xml:</p>
  
  <pre><code>&lt;struts&gt;
  
  &lt;constant name="struts.enable.DynamicMethodInvocation" value="false" /&gt;
  &lt;constant name="struts.devMode" value="true" /&gt;
  
  &lt;!-- &lt;include file="example.xml"/&gt; --&gt;
   &lt;package name="action-item" extends="struts-default"&gt;
        &lt;action name = "action_item_search_input"&gt;
        &lt;result name = "success"&gt;/action-item-search.jsp&lt;/result&gt;
      &lt;/action&gt;
      &lt;action name="action_item_search" class="gov.nasa.spacebook.ActionItemTrackingAction" method="fetchByCriteria"&gt;
         &lt;result name = "success"&gt;/action-item-result.jsp&lt;/result&gt;
         &lt;result name = "input"&gt;/action-item-search.jsp&lt;/result&gt;
         &lt;result name = "error"&gt;/action-item-search.jsp&lt;/result&gt;
      &lt;/action&gt;
   &lt;/package&gt;
   &lt;/struts&gt;
  </code></pre>
  
  <p>My action class</p>
  
  <pre><code>public class ActionItemTrackingAction extends ActionSupport {
     private List&lt;ActionItem&gt; actionItems;
     public List&lt;ActionItemTracking&gt; getActionItems() {
    return actionItems;
     }
     public void setActionItems(List&lt;ActionItemTracking&gt; actionItems) {
    this.actionItems = actionItems;
     }
  
     private String searchCriterion;
     public String getSearchCriterion() {
      return searchCriterion;
  }
  public void setSearchCriterion(final String criterion) {
      this.searchCriterion = criterion;
  }
  
      public String fetchByCriteria() throws Exception {
          final ActionItemTrackingService service = 
          new ActionItemTrackingService();
      this.actionItems = service.getByField(this.actionItem);
      return super.execute();
  }
  }
  </code></pre>