-
1. Re: WELD-001408
alesj Feb 9, 2011 4:25 AM (in response to nimo22)Do you have a UserView bean named
userView
? -
2. Re: WELD-001408
nimo22 Feb 9, 2011 5:12 AM (in response to 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 Feb 9, 2011 5:16 AM (in response to 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 Feb 9, 2011 6:13 AM (in response to nimo22)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 Feb 9, 2011 6:20 AM (in response to 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 Feb 9, 2011 6:35 AM (in response to nimo22)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.