1

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)

3
  • Are you using JSF 1.x or 2.x? Your question gives me the impression that you're still on JSF 1.x. In JSF 2.x this would be too easy with a @ManagedBean annotation or just a composite component instead of a tag file. Commented Nov 15, 2011 at 21:32
  • Is there any reason to not just use @ManagedBean? Commented Nov 15, 2011 at 22:03
  • 1
    Okay, I posted an answer. Perhaps you should take care that you are not reading tutorials/books targeted on JSF 1.x, but rather on JSF 2.x. Commented Nov 15, 2011 at 22:24

1 Answer 1

1

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 { // ... } 

See also:

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.