4 Replies Latest reply on Aug 25, 2010 12:14 PM by wangliyu

    JSF EJB's and actionListeners

    asermej

      I have been using what I believed was the new way of doing things and using EJB's (without an explicit interface) as my backing beans/controllers.  After trying to call an actionListener on the backing bean I came to the realization that ejb's can't implement an actionListener methods because the interface that would be created for you wouldn't implement the ActionListener interface.


      Is this a correct conclusion?


      Environment: weld 1.0.1 EJB 3.1 Glassfish 3.0.1

        • 1. Re: JSF EJB's and actionListeners
          wangliyu

          With EJB3.1 you should be able to put the EJB in the war file, so you can implement the ActionListener,another thing is the Listener Interfaces are in the JSF API jar. if you want to keep EJB in the EJB jar, you can put the jsf api jar in the ear/lib. This is what we do before with Seam2 and JBoss5.x,


          And of cause if you don't need transactions, you don't have to use EJBs.

          • 2. Re: JSF EJB's and actionListeners
            nickarls

            You don't have to implement any interface for the EJB itself, just do an EL-ref into a method that has the correct signature.

            • 3. Re: JSF EJB's and actionListeners
              asermej

              Thank you both for your replies.  It sounds like I am probably having an environment issue then.  I have a class that implements an actionListener method and everything is working; i.e. the EL finds and executes the method.  I then throw the @Stateless annotation on the class without changing anything else and it fails with an Expression Language can't find method error.


              I will try to simplify the code to a minimal test case and post it.

              • 4. Re: JSF EJB's and actionListeners
                wangliyu

                Check the Bean's scope, maybe you want to use @Stateful instead of @Stateless, also maybe need to implements Serializable interface.