5 Replies Latest reply on Apr 23, 2008 12:04 PM by harpritt

    Factory annotation

    harpritt

      Hi everyone


      I love SEAM but im coming back to it from a long break and im hitting memory blocks and lapse of monkey-ism.


      im trying to use the Factory anotation to populate my context variable but all i get is



      @Out attribute requires non-null value: candidateHome.genderList


      if i use the alternate approach ie annotating a method that has a return value everything works fine.


      As allways all help is greatly appreciated


      Many thanks Harps


      
      
      @Name("candidateHome")
      
      public class CandidateHome extends EntityHome<Candidate>
      
      {
      
           
      
          @RequestParameter 
      
          Long candidateId;
      
          
      
      
      
      @Out(scope = ScopeType.SESSION)
      
      public ArrayList genderList;
      
      
      @Factory(value="genderList", scope=ScopeType.SESSION)
      
      public void retrieveGendersList() {
      
      ArrayList genderList = new ArrayList<String>();
      
                genderList.add(new SelectItem("MALE"));
      
                genderList.add(new SelectItem("FEMALE"));
      
           }
      
      
      
      
      
      
          @Override
      
          public Object getId() 
      
          { 
      
              if (candidateId==null)
      
              {
      
                  return super.getId();
      
              }
      
              else
      
              {
      
                  return candidateId;
      
              }
      
          }
      
          
      
          @Override @Begin
      
          public void create() {
      
              super.create();
      
          }
      
               
      
      
      }
      
      
      
      
      
      


        • 1. Re: Factory annotation
          jazir1979

          Hi,


          In the examples I've seen on the docs, @Factory on a void method is only used when annotating the member variable as a @DataModel, never with @Out. 


          For what you are doing, all of the examples use the pattern where the method returns the value.  You've already said that approach works - so why not just use it?


          Daniel.

          • 2. Re: Factory annotation
            harpritt

            Datamodel is just an @Out wrapped for clickable rows.


            dude .... does Outjection work on Pojo's?


            lol... is this a homer moment

            • 3. Re: Factory annotation
              shane.bryzak

              You're assigning to a local variable, not the instance variable:



              ArrayList genderList = new ArrayList<String>();


              • 4. Re: Factory annotation
                harpritt

                Arrgggggg flipping hell!!!


                Hey Shane! cheers man.... a real homer momment!


                Sorry dude... hey Daniel cheer for your pointer as well.


                I spent 2.5 hrs trying to work out what i was doing wrong...



                Shane Bryzak wrote on Apr 23, 2008 03:07 AM:


                You're assigning to a local variable, not the instance variable:


                ArrayList genderList = new ArrayList<String>();





                Click HELP for text formatting instructions. Then edit this text and check the preview.

                • 5. Re: Factory annotation
                  harpritt

                  Sorted!


                  i forgot to add required is false to my Outjected component


                  Out(required=false )
                  
                  



                  Does Datamodel do this by default?