1 Reply Latest reply on Sep 25, 2008 12:42 PM by swd847

    enums as SEAM-managed components or usage of @Factory in Enums

    accless

      Is it possible / or planned to support ENUMs as SEAM-managed Components or a limitated support for enums?


      I would love to make a List of Enums available in my Frontend and place this logic in my enum-class. I was thinking about something like this in my enum-class called AllocationEditType :


         @Factory(autoCreate=true,value="allocationEditTypeRejections")
          public static List<AllocationEditType> getAllocationEditTypeRejections() {
              return AllocationEditType.getEditTypeRejections();
          }
          
          @Factory(autoCreate=true,value="allocationEditTypeAcceptances")
          public static List<AllocationEditType> getAllocationEditTypeAcceptances() {
              return AllocationEditType.getEditTypeAcceptances();
          }




      For the usage of @Factory, i have to annotate the enum-class with the @Name, otherwise the @Factory will have no affect. The @Name causes seam to instantiate the enum, which is not possible due to the nature of an enum (no public contructors allowed!) and will throw an InstantiationException.


      Isnt it a good idea/practice that seam also scans for @Factory-method in classes which dont have a name annotation?
      I dislike the Fact, that i have to create another pojo-class which makes the enums as a list available for the frontend


      Greetings


        • 1. Re: enums as SEAM-managed components or usage of @Factory in Enums
          swd847

          In all honesty you are propably better off having this functionallity in a seperate class anyway, and leave the enum as is. Using the new deployment framework in 2.1 you could probably write a custom handler for enum classes and register any factory methods you find, but IMHO having the enum list severed up by a seperate compontent just seems a lot cleaner (at any rate this is the approach I have used in my apps).


          Stuart