6 Replies Latest reply on Aug 5, 2009 7:24 AM by Daniel Yang

    h:selectOneMenu with a4j:support rendered unexpected html co

    Daniel Yang Novice

      my page code segment(index.xhtml):

       <h:selectOneMenu onchange="changed = true">
       <f:selectItem itemLabel="Item1" itemValue="1"/>
       <f:selectItem itemLabel="Item2" itemValue="2"/>
       <f:selectItem itemLabel="Item3" itemValue="3"/>
       <f:selectItem itemLabel="Item4" itemValue="4"/>
       <a4j:support event="onchange" action="#{testBean.checkItems}" ajaxSingle="true" ignoreDupResponses="true"></a4j:support>
       </h:selectOneMenu>
      


      then rendered html code:
      <select name="form1:j_id2" size="1" onchange="changed = true;"> <option value="1">Item1</option>
       <option value="2">Item2</option>
       <option value="3">Item3</option>
       <option value="4">Item4</option>
      </select>
      


      when i delete the attribute (onchange="changed = true"), it rendered correctly, but I need the attribute to ensure that the fields of the form are changed before i submit the form.
      I want to know whether it is a bug or not, or i use a4j:support in a wrong way.

      finally, i have to copy the correct rendered js snippet into my page.
      and use it as a js function like this:
      <script>
      function checkItems(){
      A4J.AJAX.Submit('_viewRoot','form1',event,{'parameters':{'form1:j_id7':'form1:j_id7','ajaxSingle':'form1:j_id2'} ,'actionUrl':'/FreeWeb/index.jsf','similarityGroupingId':'form1:j_id7','control':this,'implicitEventsQueue':'form1:j_id7','ignoreDupResponses':true} );
      }
      </script>
      
       <h:selectOneMenu onchange="changed = true; checkItems();">
       <f:selectItem itemLabel="Item1" itemValue="1"/>
       <f:selectItem itemLabel="Item2" itemValue="2"/>
       <f:selectItem itemLabel="Item3" itemValue="3"/>
       <f:selectItem itemLabel="Item4" itemValue="4"/>
       <a4j:support event="onchange" action="#{testBean.checkItems}" ajaxSingle="true" ignoreDupResponses="true"></a4j:support>
       </h:selectOneMenu>
      


      Although these code can work as i expected, but i think it is still a bad work, do you guys give me some suggestions or a better way?