Reputation: 1683
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)
Upvotes: 1
Views: 1006
Reputation: 1109635
If you annotate the backing bean class with @ManagedBean
and 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 in faces-config.xml
yourself.
@ManagedBean
@RequestScoped
public class Bean {
// ...
}
Upvotes: 1