2 Replies Latest reply on Feb 19, 2010 3:02 PM by empy

    Seam component that extends class cannot be invoked from JSF

    kiekie96

      Hi
      I have a pojo seam component (Not session bean) let say class A. This class can be invoked from my jsf page. But when i extends an abstract class like shown below
      Note: B is abstract class and dont use @Name annotation or any seam annotation


      @Name(myClass)
      public class A extends B{
      my code here
      }


      I cannot invoke any methods of A in my JSF page anymore. can seam component extends an abstract/normal class and be invoked from JSF page ?
      Do i make something wrong with my code? because if i remove the extends, everything works well.


      thx,
      Kie


        • 1. Re: Seam component that extends class cannot be invoked from JSF
          mimik789

          Hi
          I also would like to see solution/explanation for that particular case.


          Is it possible to have base class (abstract/concreate) - that share common logic for a further seam component(s) which extends that class. I would like also to use seam annotations like @Logger, to provide common logger for further seam components that extend that base class (without using @Name in that base class).


          is that even possible?
          example
          (I know that I could use @Role annotation to get similar effect, but this question is
          in general about inheritance support in Seam for it's components)



          base class (not meant to be directly created as seam component = no @Name annotation)



          public class Counter {
          
              @Logger 
              final Log log;
          
              private int count;
          
              public Counter() {
                  log.debug("counter constructed");
              }
          
          ...
          
          }








          seam components that share common logic + common logger from preceding base class


          seam comonent1 in application scope




          @Name("applicationCounterAction")
          @Scope(ScopeType.APPLICATION)
          public class ApplicationCounterAction extends Counter {
          
              public ApplicationCounterAction() {
                  log.debug("application counter constructed");
              }
              public synchronized void setCount(int count) {
                  super.setCount(count);
                  //SessionRenderer.render("all");
              }
          
          ...
          
          }






          seam component2 in session scope




          @Name("sessionCounterAction")
          @Scope(ScopeType.SESSION)
          public class SessionCounterAction extends Counter {
          
              public SessionCounterAction() {
                  log.debug("session counter constructed");
                  SessionRenderer.addCurrentSession("all");
              }
          
              public void setCount(int count) {
                  super.setCount(count);
                  //SessionRenderer.render("all");
              }
          
          ...
          
          }





          • 2. Re: Seam component that extends class cannot be invoked from JSF

            Hi,


            yep, that should work.
            It did in a similar case for me.


            regards,
            Mathias