PostConstruct « Bean « JSF Q&A

1. Why does @PostConstruct callback fire every time even though bean is @ViewScoped? JSF

I am using datatable on page and using binding attribute to bind it to my backing bean. This is my code :-

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...

2. JSTL c:forEach causes @ViewScoped bean to invoke @PostConstruct on every request

Again i see that the @PostConstruct is firing every time even though no binding attribute is used. See this code :-

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html ...

3. JSF - Bean injection trouble

As suggested by a user time ago in another question, I need to inject a bean in another bean. So, i do the following :

public class Articles {
    private ...

4. How can i send a parameter to be used in the @PostConstruct method of a backing bean?

I need to preload some data to be displayed when the page loads. The initialization steps are performed on a @PostConstruct-annotated method but now i need to use a parameter in ...

5. How to display FacesMessage from PostConstruct method of a request scoped bean?

I want to display error messages when the user first requested the page. The error is set in the post construct method of the request scoped managed bean like the following:

public ...

6. @PostConstruct didn't get called by JSF if ManagedBean is inside jar library

I'm running with the following problem. I have a few Managed Beans that are shared between, at this moment, two JSF applications. As I don't want to copy and paste the code ...

7. Porting functionality of a managed bean while migrating from Core JSF to Seam

I used to initialize certain properties of an entity object with pre-defined values as early as its instantiation in a @PostConstruct method of a jsf managed bean (or even the managed ...