1 Reply Latest reply on Sep 5, 2007 1:05 PM by Ilya Shaikovsky

    actionListener inside h:selectOneMenu

    Lucas de Oliveira Newbie

      Hi there!
      I have a xhtml file that needs to call a method when a selection inside a h:selectOneMenu happens. I used actionListener on the a:support because I needed more power (e.g. to know from which UIComponent the event comes from).

      The problem is that the method defined by the actionListener is never called at all.

      I've tried to do that with valueChangeListener as well but I needed to verify if the user selects a non valid object (noSelecionLabel).

      my xhtml:

      (...)
       <h:outputText value="#{messages['gerenciarorcamento.label.cidadefrete']}"></h:outputText>
       <h:selectOneMenu value="#{orcamento.frete}" required="true" styleClass="azul11"
       enabledClass="azul11" >
       <s:selectItems
       value="#{freteDAO.fretes}"
       var="frete"
       label="#{frete.cidade.nome}"
      noSelectionLabel="#{messages['gerenciarorcamentos.label.semfrete']}"/>
      
       <a:support actionListener="#{gerenciarOrcamentos.selecionaFrete}"
       event="onchange" status="ajaxStatus" oncomplete="alert"
       reRender="panelInfoFrete"/>
      
       </h:selectOneMenu>
      (...)
      


      So when I select an item inside the selectOneMenu I want to verify if it's a valid one (non-String, in case the user select the noSelectionLabel item) or
      a valid object.

      my bean:
      (...)
       public void selecionaFrete(ActionEvent ae) {
       log.info("\n\nCOMPONENTE: "+((HtmlAjaxSupport)ae.getSource()).getParent());
       log.info("\n\nSELECAO: "+(((HtmlAjaxSupport)ae.getSource()).getParent()));
       try{
       Frete frete = (Frete)((UISelectItems)((HtmlAjaxSupport)ae.getSource()).getParent()).getValue();
       log.info("SELECIONANDO FRETE");
       }catch (Exception e) {
       log.info("Nao conseguiu transformar a linha em MateriaPrimaPerfil");
       }
       }
      (...)
      


      This method is never called at all.

      my bean interface:
      (...)
       public void selecionaFrete(ActionEvent ae);
      (...)
      


      Any ideas?

      thanks in advance!
      cheers!