6 Replies Latest reply on Jul 25, 2013 6:21 AM by specialed

    CDI/WELD referrencing a custom qualifier from html (xhtml) page directly

    specialed Newbie

      Hi all,


      I've started a question over @StackOverflow and would like to know what this community is thinking about it:






      While having a custom qualifier for CDI support as followed:




          @Target({METHOD, FIELD, PARAMETER, TYPE})

          public @interface QualifiedFooBean {





          public class FooBean implements ImplFooBean {



          @Inject @QAnotherBean

          private ImplAnotherBean otherBean;



          private ConfigBean configBean; //no custom qualifier required (no interface)




          public interface ImplFooBean {




      I would like to bind FooBean #{fooBean} directly without requiring a wrapper or processor (seen from many examples). The annotation "Named" (in class FooBean) seems not to work for my class layout. I would like to know if there are any other solutions instead of a wrapper, otherwise code will seem overbloated and all my static pages are already referring to #{fooBean}.



      Wrapper solution:




          public class FooBeanProcessor implements Serializable {



          @Inject @QualifiedFooBean

          private ImplFooBean fooBean;



          //getter and setter for FooBean required





      I have to create two additional classes in order to migrate my project from JSF annotations to CDI/Weld. Or maybe I'm not aware of the whole potential of CDI. If there aren't any other ways, I'll be required to choose the wrapper solution. Has anyone any idea?