3 Replies Latest reply on May 18, 2007 11:37 AM by Monkey Den

    @Factory method get called first..

    Mahesh Shinde Newbie


      I am using @Factory method and As the behaviour of @Factory method it is called everytime at first. But my requirement is I first want to add filter into the query object and then retrieve the records. To inject filter parameters I am calling one method setFilters()

      @In(required = false)
      @Out(required = false)
      private Article article;
      public List getMainFormData() {
      public String setFilters() {
      return "mainForm.xhtml";

      When I calll setFilter method by h:commandButton , Instead of setFilter method it is calling @Factory method and then setFilter method..

      Which gives me wrong result....

      Please suggest where I am doing wrong!

        • 1. Re: @Factory method get called first..
          Monkey Den Master

          You're not doing anything wrong. This is just the way it behaves. I'm sure there is a lot more which happens but most basically it's this:

          1. The commandButton initiates the request
          2. Seam creates the component, if it doesn't exist
          3. Performs any and all injection for the component
          4. Those data members which have factory methods associated, Seam invokes the methods
          5. If a @Create method is defined, Seam calls it
          6. The originally requested action method is invoked.

          • 2. Re: @Factory method get called first..
            Mahesh Shinde Newbie

            Means there is know way to get filtered records from Factory method...

            Do u have any another solution for this situation.

            • 3. Re: @Factory method get called first..
              Monkey Den Master

              Not when that filter needs to be injected. I don't know the specific requirement but if it exists already, you could get it explicitly in the factory method.

              public List getMainFormData() {
               Context session = Contexts.getSessionContext();
               Object obj = sesison.get("myFilter");

              or look it up in the DB:

              public List getMainFormData() {
               MyBO bo = new MyBO();

              ...or get it from wherever else it might originate.