开发者

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

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?

Tha开发者_C百科nk you.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜