I have jsf application in which I have to use a facelet custom component (defined in a custom tag library). In order to achieve this I have done the following:
– created the component, with ui:component
– created the taglib in a file person.taglib.xml
– create the context parameter in web.xml
– and finally included the component in a xhtml document
But I need to use a bean, in order to get the information that I have to display. Can I use a bean inside a facelet component definition?
For example, I have a created a pure jsp page, including jsf tags, and from there I can access the bean (for example Person).
Can I access the bean defined in faces-config.xml from a facelet component?
(Hope I was clear enough)
If you annotate the backing bean class with
@ManagedBeanand put that class just straight in the classpath, either plain vanilla or inside a JAR with a/META-INF/faces-config.xml, then JSF2 will auto-register it as a managed bean without any need to register it infaces-config.xmlyourself.See also: