0 Replies Latest reply on Nov 7, 2007 8:51 AM by trajber

    a4j and selectOneMenu's valueChangeListener

    trajber

      Hi all,

      I'm just building an simple application that loads some items inside a selectOneMenu when a onblur event occurs in a inputText.So far everything is going well.
      The problem starts when a try to add a valueChangeListener to the selectOneMenu and also add a a4j support linked to onChange event.
      When I reproduce the onblur event for the second time OR when I change the combo value an java.util.NoSuchElementException is throwed.

      Can you help me ?

      Thats the cursed code ;-)

      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
      
      
      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
      <title>Insert title here</title>
      </head>
      <body>
      
      <f:view>
       <h:form id="form">
      
       <rich:panel style="border:none" id="parent">
      
       <h:inputText value="#{testeForm.inputText}">
       <a4j:support event="onblur" actionListener="#{testeForm.loadItems}"
       reRender="parent">
       </a4j:support>
       </h:inputText>
      
      
       <h:selectOneMenu valueChangeListener="#{testeForm.change}" value="#{testeForm.id}">
       <a4j:support event="onchange"></a4j:support>
       <f:selectItems value="#{testeForm.items}" />
       </h:selectOneMenu>
      
       </rich:panel>
      
       </h:form>
      </f:view>
      </body>
      </html>
      


      public class TesteForm {
      
       private List<SelectItem> items;
       private String inputText;
       private Integer id;
      
      
       @PostConstruct
       public void init(){
       items = new ArrayList<SelectItem>();
       }
      
       public List<SelectItem> getItems() {
       return items;
       }
      
       public void setItems(List<SelectItem> items) {
       this.items = items;
       }
      
      
      
       public Integer getId() {
       return id;
       }
      
       public void setId(Integer id) {
       this.id = id;
       }
      
       public String getInputText() {
       return inputText;
       }
      
       public void setInputText(String inputText) {
       this.inputText = inputText;
       }
      
       public void loadItems(ActionEvent event) {
       for (int x = 0; x < 5; x++){
       items.add(new SelectItem(x,x+""));
       }
       }
      
       public void change(ValueChangeEvent changeEvent) {
       System.out.println("HELLO");
       }
      
      
      }