Reputation: 489
I have method getStudents on managed BackBean, I am calling getstudents which inturn makes a call to database and fetches the data. The UI shows properly, but its causing performance issue as it takes too much time to load the page . Please suggest me how to handle this performance issue.
Upvotes: 1
Views: 574
Reputation: 14277
You should no do business logic in getter methods. You should init your list in @PostConstruct
method or do lazy loading in getter:
private List myList;
@PostConstruct
public void init() {
// init my List
}
// getter and setter
@PostConstruct
method will be called after managed bean instantiation. I suggest you to init in this method, not in constructor. As you are changing your list during the backing bean life, you should update it when it is changed. You can add data which was created by user, or you can chose to call database again after inserting values. You have to worry about this, there is no automation.
Upvotes: 3