Data provider method in apache click

143 views Asked by At

Can the data provider method be only written onInit() method of apache click or can it be written in any someother method too?

2

There are 2 answers

0
Bob Schellink On

No, you could add it pretty much anywhere as long as the provider is available when the control gets rendered. Adding the provider in the onInit or Page constructor is simply the most common place to use.

0
Gilberto On

The DataProvider is a control's interface and following the Page[1] initialization sequence, the best place to setup that interface is on the Page's onInit() method[2]:

For initializing page controls the best practice is to place all the control creation code in the pages constructor, and only place any initialization code in the onInit() method which has an external dependency to the context or some other object. By following this practice it is easy to see what code is "design time" initialization code and what is "runtime initialization code".

The following article[3] will help you understand how to use DataProviders.

Gilberto

[1] http://click.apache.org/docs/click-api/org/apache/click/Page.html

[2] http://click.apache.org/docs/click-api/org/apache/click/Page.html#onInit()

[3] http://click-framework.blogspot.com.br/2010/07/apache-click-220-dataprovider.html