-
1. Re: How to execute an action when the custom composite component
lightguard Feb 8, 2012 11:11 AM (in response to hantsy)This would be one of those holes in JSF 2 and CDI integration which will be fixed in JSF 2.2. You could lookup the BeanManager via JNDI and query that way.
-
2. Re: How to execute an action when the custom composite component
hantsy Feb 9, 2012 9:19 AM (in response to lightguard)Is there another solution for this purpose...?
I can not find a example about writing a Custom Component for the composite component, and provide custom action/method/event for the custome Component and how to interact with the children of the custom Component...
Any help here?
-
3. Re: How to execute an action when the custom composite component
bleathem Feb 9, 2012 9:20 PM (in response to hantsy)@Inject @Named("baseCurrency") Currency baseCurrency;
FYI: Even if you could @Inject into a component, this is a wrong use of @Named. @Inject is resolved by type, not by name.
As Jason said, you cannot currently use CDI injection in a JSF component. You'll have to ask the BeanManager for it, which is pretty simple to do.
Backstory: Seam Faces stores a reference to the BeanManager in the Faces ServletContext, and provides access to the BeanManager using the BeanManagerProvider interface.
Solution: This can be leveraged in your FacesComponent by using the Solder BeanManagerLocator#getBeanManager method. Once you have a reference to the BeanManager, use one of the BeanManager#getBeans methods to look for the bean you were trying to inject.
However, that being said, typically one feeds data into a component with a value binding. You would bind "baseCurrency" to an attribute of your object, and look it up using the UIComponent#getAttribute method.
-
4. Re: How to execute an action when the custom composite component
zeeman Feb 10, 2012 12:38 AM (in response to bleathem)I tried doing some custom components and they're a hack in JSF2. There are many issues with them.
I saved myself a lot of pain by staying away from custom components. The best componetization you'll get with JSF2 is passing params to pages and include those pages where you need them.