6 Replies Latest reply on Feb 9, 2011 6:35 AM by ssachtleben.ssachtleben.gmail.com

    WELD-001408

    nimo22

      I have this:




      @Named @SessionScoped
      public class MyBean implements Serializable{
      
      private static final long serialVersionUID = -...;
      
      @Inject @Named
      private UserView userView;
      
      ..
      }



      and get this error:



      WELD-001408 Unsatisfied dependencies for type [UserView] with qualifiers [@Named] at injection point [[field] @Inject @Named private com.MyBean.userView]



      The Docs says that I can do something like this:


      Example usage:



      public class Car {
           @Inject @Named("driver") Seat driverSeat;
           @Inject @Named("passenger") Seat passengerSeat;





      But it does not work. Why? I am using weld 1.1 final.


        • 1. Re: WELD-001408
          alesj

          Do you have a UserView bean named userView?

          • 2. Re: WELD-001408
            nimo22

            No:


            public class UserView implements Serializable{
            
            private static final long serialVersionUID = -...;
            
            ..
            }



            @Inject @Named
            private UserView userView;


            does not defaults to the name userView ? So I have to use this?:


            @Inject @Named(userView)
            private UserView userView;


            Welcome to type-safety in @Named-Annotations;)

            • 3. Re: WELD-001408
              nimo22

              When using this:


              @Inject @Named private UserView userView;


              what is the default-(string-based)-name I can use in EL?


              #{userView}

              ?


              I have thought it begins decapitalized..

              • 4. Re: WELD-001408
                ssachtleben.ssachtleben.gmail.com

                Thats true! @Named(userView) equals to @Named if beans name is UserView!


                If you want to access in faclet via


                #{userView}



                you have to use this:


                @Produces @Named public UserView getUserView() { 
                  return userView; 
                }





                • 5. Re: WELD-001408
                  nimo22

                  yes, with produces it works. But you see in the doc:


                  public class Car {
                       @Inject @Named(driver) Seat driverSeat;
                       @Inject @Named(passenger) Seat passengerSeat;


                  there is no produces!


                  So should I assume, that Seat is produced in aother bean?


                  With this


                  @Inject @New @Named(driver) Seat driverSeat;


                  it would be clearer.



                  • 6. Re: WELD-001408
                    ssachtleben.ssachtleben.gmail.com

                    yep for @Inject something you need a @Named bean or @Produces method/property.


                    so if you have in one bean this part:


                    @Produces List<Category> categories;



                    you can use in all other managed beans:


                    @Inject List<Category> categories;



                    to fetch the list from your first bean.