title: JSF not firing bean setters when using f:ajax
body: <p>This is an update on a previous <a href="https://stackoverflow.com/questions/13454295/jsf-condtional-rendering-based-on-menu-value">post</a> I made regarding conditional rendering of page components.  I can now conditionally render different components on the page based on selected user inputs using the f:ajax tag.  The trouble is that when I click my commandbutton the inputs that are conditionally rendered using ajax aren't being read on submit.  I am guessing it is because the whole page isn't rerendered when I add in the new components and the submit button can't see them, even though they are there.  Here is the segment of my form page(it is wrapped in a h:form tag):</p>
  <pre><code>            &lt;h:outputLabel for=&quot;selectPersonType&quot; value=&quot;Select Type: &quot;/&gt;
              &lt;h:selectOneMenu id=&quot;selectPersonType&quot; value=&quot;#{addPersonBean.personType}&quot; label=&quot;Person Type&quot; required=&quot;true&quot;&gt;
                  &lt;f:selectItem itemValue=&quot;&quot;/&gt;
                  &lt;f:selectItems value=&quot;#{listBean.personTypes}&quot; /&gt;
                  &lt;f:ajax render=&quot;results&quot;/&gt;
              &lt;/h:selectOneMenu&gt;
              &lt;h:message for=&quot;selectPersonType&quot; style=&quot;color: red&quot;/&gt;
          &lt;/h:panelGrid&gt;
  
          &lt;h:panelGroup id=&quot;results&quot;&gt;
              
              &lt;h:panelGroup rendered=&quot;#{addPersonBean.personType == 'STUDENT'}&quot;&gt;
                  &lt;h:outputLabel for=&quot;selectSchoolType&quot; value=&quot;School Type: &quot; /&gt;
                  &lt;h:selectOneMenu id=&quot;selectSchoolType&quot; value=&quot;#{addPersonBean.schoolType}&quot;&gt;
                      &lt;f:selectItems value=&quot;#{listBean.schoolTypes}&quot; /&gt;
                      &lt;f:ajax execute=&quot;selectSchoolType&quot;/&gt;
                  &lt;/h:selectOneMenu&gt;
              &lt;/h:panelGroup&gt;
              
              &lt;h:panelGroup rendered=&quot;#{addPersonBean.personType == 'PATIENT'}&quot;&gt;
                  &lt;h:outputLabel for=&quot;smoker&quot; value=&quot;Smoker? &quot; /&gt;
                  &lt;h:selectBooleanCheckbox id=&quot;smoker&quot; value=&quot;#{addPersonBean.smoker}&quot;&gt;
                      &lt;f:ajax execute=&quot;smoker&quot;/&gt;
                  &lt;/h:selectBooleanCheckbox&gt;
    
              &lt;/h:panelGroup&gt;
          &lt;/h:panelGroup&gt;
  
          &lt;h:commandButton value=&quot;Add Person&quot; action=&quot;#{addPersonBean.action}&quot;/&gt;
  </code></pre>
  <p>The trouble here is that the components with ids 'selectSchoolType' and 'smoker's values don't get set when I click the commandButton because they are rendered conditionally using the selectPersonType select menu after the page has loaded.  Is there a way to fire the components when their values change instead of when I click the submit button (therefore, their values should be processed before I even click submit).  As you can see I have tried to use f:ajax with the execute attribute attached to the components in question but it didn't seem to work.  (I believe the default events for these components are valueChange so haven't added them to the f:ajax tags, but I have tried 'change' and 'valueChange').</p>