0

Can you guys help me to explain the reason why the method is called multiple times when I used the h:dataTable in facelet page.

 <h:dataTable id="listTable" styleClass="pageView_listForm"
 value="#{ClassName.dataFactory(topic)}" border="2" rules="rows" 
var="item" width="100%" cellpadding="1" cellspacing="0" rowClasses="panelRowOdd,panelRowEven" >
        //Body
        </h:dataTable>

Bean class

@ManagedBean (name="ClassName")
@SessionScoped
public class ClassName{
   ...
     public DataModel <Person> dataFactory(String topic){
       DataModel items = null;  
       ..........
       // This block code gets the list of Person
       ..........
       return items;
    }

}

I was launching the page when it called the method dataFactory multiple times. I did not know exactly what happen here? Is it a bug from JSF or my implementation.Can you guy help me?

Thank you.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
miller
  • 3
  • 1
  • 2
  • possible duplicate of [Why JSF calls getters multiple times](http://stackoverflow.com/questions/2090033/why-jsf-calls-getters-multiple-times) – BalusC Jul 07 '11 at 18:03

1 Answers1

0

when happens with Datatable, we should take care that such a method should not contain much business logic, Or Database interactions which are costly.

here i found some useful discussions....

Why JSF calls getters multiple times

Why is BackingBean method called multiple times when requesting facelet?

This

and here

Calling a method multiple times when using h:dataTable in JSF

Community
  • 1
  • 1
Maddy
  • 3,726
  • 9
  • 41
  • 55