3 Replies Latest reply on May 6, 2008 11:41 AM by Kerdudou Ronan

    'onchange' event in a a4j:support for a h:selectOneMenu in a

    Kerdudou Ronan Apprentice

      Hi richfaces guys,

      As in one of my previous post, I can't make a4:support working as expected for a selectOneMenu in a datatable. Whatever the selected row, it is always the first one that is updated.

      Here is the jsp page code snippet to reproduce this.

      <h:form id="form">
       <rich:dataTable value="#{testBean.list}" var="item" id="table">
       <rich:column>
       <h:selectOneMenu value="#{item.value}"
       id="selectOneMenu" >
       <a4j:support
       ajaxSingle="true" event="onclick" reRender="input, output"/>
       <f:selectItems value="#{testBean.values}"/>
       </h:selectOneMenu>
       </rich:column>
       <rich:column>
       <h:inputText id="input" value="#{item.value}">
       <a4j:support ajaxSingle="true" event="onchange"
       reRender="selectOneMenu, output"/>
       </h:inputText>
       </rich:column>
       <rich:column >
       <h:outputText id="output" value="#{item.value}"/>
       </rich:column>
       </rich:dataTable>
       </h:form>


      The TestBean code :
      public class TestBean {
      
       private List<BeanKeyValue> list = new ArrayList<BeanKeyValue>();
      
       private List<SelectItem> values = new ArrayList<SelectItem>();
      
       public TestHandler() {
       list.add(new BeanKeyValue("1","1"));
       list.add(new BeanKeyValue("2","2" ));
       list.add(new BeanKeyValue("3","3"));
       list.add(new BeanKeyValue("4","4"));
       list.add(new BeanKeyValue("5","5"));
      
       values.add(new SelectItem("1", "1"));
       values.add(new SelectItem("2", "2"));
       values.add(new SelectItem("3", "3"));
       values.add(new SelectItem("4", "4"));
       values.add(new SelectItem("5", "5"));
       }
       public List<BeanKeyValue> getList() {
       return list;
       }
      
       public void setList(List<BeanKeyValue> list) {
       this.list = list;
       }
      
       public List getValues() {
       return values;
       }
      }


      The TestBean can be in session or in request scope.

      When I update the value with the inputText, my page is correctly updated (selectOneMenu and output are rerendered).
      When I update the value with the SelectOneMenu, my page is updated (input and output are NOT rerendered).

      We can see the following in the sent ajax request:
      onchange on the inputText:
      ajaxSingle=form%3Atable%3A3%3Ainput

      onchange on the selectOneMenu:
      ajaxSingle=form%3Atable%3A0%3AselectOneMenu&

      onclick on the selectOneMenu:
      ajaxSingle=form%3Atable%3A3%3AselectOneMenu&


      I have the same problem with an inputText with a 'onchange' a4j:support but in a rich:subtable.

      Thanks for your help.