title: populate one dropdown on selection of other using struts2 dojo tags
body: <p>I have two dropdowns. I want to populate the second dropdown on selection of first dropdown.
  I am using struts-dojo-tags for accomplishing this.</p>
  
  <pre><code>&lt;%@ page contentType="text/html; charset=UTF-8"%&gt;
  &lt;%@ taglib prefix="s" uri="/struts-tags"%&gt;
  &lt;%@ taglib prefix="sx" uri="/struts-dojo-tags"%&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Welcome&lt;/title&gt;
  &lt;script&gt;
  &lt;/script&gt;
  &lt;sx:head /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h2&gt;Struts 2 + Ajax Example 2!&lt;/h2&gt;
  &lt;s:form name="f1"&gt;
  &lt;s:textfield name="proj" label="Project Name" /&gt;
  &lt;s:url id="url" value="/populateStates.action" /&gt;
  &lt;s:select id="id1" list="countryList"
      listKey="countryId" listValue="countryName" headerKey="0"
      headerValue="-Select-" label="Country"/&gt;
  &lt;s:select id="id2" list="list2" listKey="stateId"
      listValue="stateName" headerKey="0" headerValue="-Select-"
      label="State" /&gt;
  &lt;sx:bind sources="id1" targets="id2" events="onchange"
      href="%{#url}" /&gt;
  &lt;/s:form&gt;
  &lt;br&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My action class has two action methods. </p>
  
  <pre><code>        public String populateCountry() throws Exception{
  
      list1 = new ArrayList&lt;Country&gt;();
      list1.add(new Country(1, "Country1"));
      list1.add(new Country(2, "Country2"));
      list1.add(new Country(3, "Country3"));
  
      return SUCCESS;
  }
  
  public String populateStates() throws Exception{
  
      System.out.println("populateStates******************"+id1);
  
      list2 = new ArrayList&lt;State&gt;();
  
      if (id1 != null &amp;&amp; !id1.equals("")) 
      {   
          if(id1.equals("1"))
          {
              list2.add(new State(1, "UMB1"));
              list2.add(new State(2, "UMB2"));
              list2.add(new State(3, "UMB3"));
          }
          else if(id1.equals("2"))
          {
              list2.add(new State(4, "UMB4"));
              list2.add(new State(5, "UMB5"));
              list2.add(new State(6, "UMB6"));
          }
          else if(id1.equals("3"))
          {
              list2.add(new State(7, "UMB7"));
              list2.add(new State(8, "UMB8"));
              list2.add(new State(9, "UMB9"));
          }       
      }
      return SUCCESS;
  }
  </code></pre>
  
  <p>First action method is called when the jsp is loaded the first time (with populated <code>Country</code> drop down) and second action method is called when I select a country from the <code>Country</code> dropdown.</p>
  
  <p>Problem: <code>States</code> drop down is not getting populated. When I debug the code, I see that when control reaches <code>populateStates</code> all the variables of my <code>Action</code> class are reset(id1, id2, list1, list2, proj). Due to which I get an empty States dropdown. Please help me to solve this issue.  </p>