2 Replies Latest reply on Jun 4, 2008 4:37 AM by ilya_shaikovsky

    Fire ActionListener from method

      Hi,

      i need fire an ActionListener from a method. omething like this:

      public void someMethod(ActionEvent event) {
       //Do something
       //Fire an ActionListener
      
      }
      


      How can i do that?
      Another solution is add more than one ActionListener to the same component (HtmlAjaxCommandLink). Is it possible?

      Thanks a lot




        • 1. Re: Fire ActionListener from method

          Solved. I found a solution:

          public class MenuClickEvent implements ActionListener {
          
           @Override
           public void processAction(ActionEvent event) throws AbortProcessingException {
           HtmlAjaxCommandLink cl = (HtmlAjaxCommandLink)event.getSource();
           ItemMenu itemMenu = (ItemMenu) cl.getAttributes().get("itemMenu");
          
           FacesContext fc = FacesContext.getCurrentInstance();
           TelaPrincipal telaPrincipal = (TelaPrincipal) fc.getApplication().getVariableResolver().resolveVariable(fc, "telaPrincipal");
           telaPrincipal.setMenuAtual(itemMenu.getPai().getTexto()+" > "+itemMenu.getTexto());
           }
          
          }
          



          HtmlAjaxCommandLink clItemMenu = new HtmlAjaxCommandLink();
          clItemMenu.addActionListener(new MenuClickEvent());
          


          Now I can add multiple classes that implement ActionListener.

          • 2. Re: Fire ActionListener from method
            ilya_shaikovsky

             

            Another solution is add more than one ActionListener to the same component (HtmlAjaxCommandLink). Is it possible?


            use a few
            f:actionListener
            nested to your component ;)