title: Ajax Listener event valueChange seems to be firing onClick instead of onChange
body: <p>I have a nested list of Questions that I'd like to display.  Initially, I'm displaying the Level 1 questions and then subquestions are displayed based on the users answers to the their parent question.  All questions have a radio button and some questions have an input box for additional information that is shown when user selects "Yes"</p>
  
  <p>Here is my JSF code with nested dataTables.  Please note that I have pulled out formatting of these questions in order to simply the question on the forum, so these may look "unpretty" if you copy this code into your own environment and run the code:</p>
  
  <pre><code>&lt;h:dataTable id="questionTable" var="q" value="#{generalQuestionBean2.questions.questions}"&gt;
  &lt;h:column&gt;&lt;h:panelGroup id="questionGrp"&gt;
  #{q.question} &lt;h:selectOneRadio value="#{q.answer}"&gt;
  &lt;f:selectItem itemValue="1" itemLabel="Yes"/&gt;
  &lt;f:selectItem itemValue="0" itemLabel="No"/&gt;
  &lt;f:ajax event="valueChange" execute="@form"
      render="questionGrp"
      listener="#{generalQuestionBean2.reset}"/&gt;
  &lt;/h:selectOneRadio&gt; &lt;h:inputText value="#{q.addnInfo}"
  rendered="#{q.answer eq '1' and q.field ne 'otherCov'}"&gt;&lt;/h:inputText&gt;
  
  &lt;h:panelGroup id="questionGrpSubs" rendered="#{q.addnQuestions ne null and q.answer eq '1'}"&gt;
  &lt;h:dataTable id="subQuestionTable" var="subq" value="#{q.addnQuestions}"&gt;
  &lt;h:column&gt;&lt;h:panelGroup id="subQuestionGrp"&gt;
  -&gt;#{subq.question} &lt;h:selectOneRadio id="answer" value="#{subq.answer}"&gt; 
   &lt;f:selectItem itemValue="1" itemLabel="Yes"/&gt;
   &lt;f:selectItem itemValue="0" itemLabel="No"/&gt;
   &lt;f:ajax event="valueChange" execute="@form"
      render="subQuestionGrp"
      listener="#{generalQuestionBean2.reset}"/&gt;
  &lt;/h:selectOneRadio&gt;&lt;h:inputText value="#{subq.addnInfo}"
  rendered="#{subq.answer eq '1' and subq.field ne 'voluntaryComp' and subq.field ne 'uslh'}"&gt;&lt;/h:inputText&gt;
  
  &lt;h:panelGroup id="questionGrpSubs2" rendered="#{subq.addnQuestions ne null and subq.answer eq '1'}"&gt;
  &lt;h:dataTable id="sub2QuestionTable" var="sub2q" value="#{subq.addnQuestions}"&gt;
  &lt;h:column&gt;&lt;h:panelGroup id="sub2QuestionGrp"&gt;
  --&gt;#{sub2q.question} &lt;h:selectOneRadio id="answer" value="#{sub2q.answer}"&gt; 
   &lt;f:selectItem itemValue="1" itemLabel="Yes"/&gt;
   &lt;f:selectItem itemValue="0" itemLabel="No"/&gt;
   &lt;f:ajax event="valueChange" execute="@form"
      render="sub2QuestionGrp"
      listener="#{generalQuestionBean2.reset}"/&gt;
  &lt;/h:selectOneRadio&gt;&lt;h:inputText value="#{sub2q.addnInfo}"
  rendered="#{sub2q.answer eq '1'}"&gt;&lt;/h:inputText&gt;
  
  &lt;/h:panelGroup&gt;&lt;/h:column&gt;
  &lt;/h:dataTable&gt;&lt;/h:panelGroup&gt;
  &lt;/h:panelGroup&gt;&lt;/h:column&gt;
  &lt;/h:dataTable&gt;&lt;/h:panelGroup&gt;
  &lt;/h:panelGroup&gt;&lt;/h:column&gt;
  &lt;/h:dataTable&gt;
  </code></pre>
  
  <p>Here is the code for the reset function on the backing bean:</p>
  
  <pre><code>private void reset(AjaxBehaviorEvent event) {
      FacesContext context = FacesContext.getCurrentInstance();
      String id = event.getComponent().getClientId(context);
      String[] tokens = id.split("[:]+");
      int qId = -1;
      int subqId = -1;
      int sub2qId = -1;
      for (int i = 0; i &lt; tokens.length; i++) {
          if(tokens[i].equals("questionTable")) 
              qId = Integer.parseInt(tokens[i+1]);
          if(tokens[i].equals("subQuestionTable"))
              subqId = Integer.parseInt(tokens[i+1]);
          if(tokens[i].equals("sub2QuestionTable"))
              sub2qId = Integer.parseInt(tokens[i+1]);
  
      }
      Question q = questions.getQuestion(qId);
      Question processQ = q;
      String defaultSubAnswer = getDefaultSubAnswer(q.getField());
      Question subq;
      Question subq2;
      if(subqId &gt; -1) {
          subq = q.getAddnQuestions().get(subqId);
          processQ = subq;
          if(sub2qId &gt; -1) {
              subq2 = subq.getAddnQuestions().get(sub2qId);
              processQ = subq2;
          }
      }
      resetValue(processQ, defaultSubAnswer);
  }
  
  
  private void resetValue(Question q, String defaultSubAnswer) {
      q.setAddnInfo("");
      if(q.getAddnQuestions() != null) {
          for (int i = 0; i &lt; q.getAddnQuestions().size(); i++) {
              Question subq = q.getAddnQuestions().get(i);
              subq.setAnswer(defaultSubAnswer);
              resetValue(subq, defaultSubAnswer);
          }
      }
  }
  </code></pre>
  
  <p>Here is the problem:</p>
  
  <p>The ajax event should default to "valueChange".  If I click on "Yes" and then "Yes" again, the ajax call should not happen, correct?  But it is, as the Additional Info box is clearing out based on the reset function.</p>
  
  <p>I had originally tried adding a condition to the reset function to check the value of the button that was clicked and only reset the addnInfo value and subquestions if the answer is "0" (No).  But this was causing issues with the rendering as the ajax call would render the input box and subquestions to hide and the value would be held onto on the front end, even though they're reset on the backing bean.  When they re-rendered to the front in, the value that was held onto shows up instead of the value in the backing bean.</p>
  
  <p>Another attempt was using a ValueChangeListener for the reset of the values. But this still has the same issue with the value being held onto when re-rendering.</p>
  
  <p>I have tried 3 different approaches (listed above) and all have failed.  I'm open to hearing a solution to any of these or possibly another solution.  Keep in mind that formatting limitations by the users leaves me with less options to work with.</p>