title: How can I tell Struts2 not to validate a form the first time it displays?
body: <p>I'm currently trying to learn Struts2.</p>
  
  <p>I've created a form, an action to process it, an XML to validate it, and actions in the struts.xml.</p>
  
  <p>Every time the form displays, even the first time, Struts2 tries to validate, so errors are displayed before the user had a chance to complete it.</p>
  
  <p>Here is the relevant code:</p>
  
  <pre><code>&lt;!-- /WebContent/views/user/login.jsp --&gt;
  &lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;
  &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib prefix="s" uri="/struts-tags" %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Login Page&lt;/title&gt;
  &lt;s:head /&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;Login Page&lt;/h1&gt;
      &lt;s:form action="executeUser"&gt;
          &lt;s:textfield key="userBean.userName" /&gt;
          &lt;s:password key="userBean.password" /&gt;
          &lt;s:submit align="center" /&gt;
      &lt;/s:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;!-- /src/struts.xml --&gt;
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE struts PUBLIC
      "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
      "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;
  
  &lt;struts&gt;
  
      &lt;constant name="struts.devMode" value="true" /&gt;
  
      &lt;package name="overviewofstruts" extends="struts-default"&gt;
          &lt;action name="loginUser" class="hu.flux.user.LoginUserAction" method="execute"&gt;
              &lt;result name="input"&gt;/views/user/login.jsp&lt;/result&gt;
          &lt;/action&gt;
  
          &lt;action name="executeUser" class="hu.flux.user.LoginUserAction" method="execute"&gt;
              &lt;result name="input"&gt;/views/user/login.jsp&lt;/result&gt;
              &lt;result name="success"&gt;/views/user/login_thankyou.jsp&lt;/result&gt;
          &lt;/action&gt;
      &lt;/package&gt;
  
  &lt;/struts&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>// /src/hu/flux/user/LoginUserAction.java
  package hu.flux.user;
  import java.util.Map;
  import com.opensymphony.xwork2.ActionContext;
  import com.opensymphony.xwork2.ActionSupport;
  
  public class LoginUserAction extends ActionSupport {
  
      private User userBean;
      public void setUserBean(User userBean) { this.userBean = userBean; }
      public User getUserBean() { return userBean; }
  
      public String login() throws Exception { return this.execute(); }
      public String execute() throws Exception { return  SUCCESS; }
      public String input() throws Exception { return INPUT; }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;!-- // /src/hu/flux/user/LoginUserAction-validation.xml --&gt;
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &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;validator type="requiredstring"&gt;
      &lt;param name="fieldname"&gt;userBean.userName&lt;/param&gt;
      &lt;message&gt;Username is required.&lt;/message&gt;
   &lt;/validator&gt;
   &lt;validator type="requiredstring"&gt;
      &lt;param name="fieldname"&gt;userBean.password&lt;/param&gt;
      &lt;message&gt;Password is required.&lt;/message&gt;
   &lt;/validator&gt;
  </code></pre>
  
  <p></p>
  
  <hr>
  
  <p>What do I need to do or change to get struts to show the form the first time without complaining about all the blank fields?</p>