3

I want to design a report to show Customer data (cust code,Name) and the header link should be sortable. I am using Scripted data source. I implemented a CustomerHandler class like below:

CustomerHandler class:

public class CustomerHandler extends ScriptedDataSetEventAdapter {

List<CustomerBean> customerList;
Iterator itr = null;

int i = 0;
CustomerBean bean;



@Override
public void beforeOpen(IDataSetInstance dataSet,
IReportContext reportContext) throws ScriptException {
// TODO Auto-generated method stub
super.beforeOpen(dataSet, reportContext);

customerList = new ArrayList<CustomerBean>();

customerList.add(new CustomerBean("DIVERS","Diversified Ridder"));
customerList.add(new CustomerBean("Pranav","Pranav Kumar"));
customerList.add(new CustomerBean("Jyoti","jyoi kar"));

}

@Override
public void open(IDataSetInstance dataSet) throws ScriptException {
// TODO Auto-generated method stub
super.open(dataSet);

if(customerList != null && customerList.size() > 0)
bean = customerList.get(i);
}

@Override
public boolean fetch(IDataSetInstance dataSet, IUpdatableDataSetRow row)
throws ScriptException {

if(i == customerList.size()) {
//System.out.println("Last:::"+bean.getCustCode());
//row.setColumnValue("CUST_CODE", bean.getCustCode());
return false;
}


row.setColumnValue("CUST_CODE", bean.getCustCode());
row.setColumnValue("NAME", bean.getName());
//System.out.println(bean.getCustCode());
i++;
if(i < customerList.size()) bean = customerList.get(i);
return true; // to indicate that more rows to follow


}


}

Also I am attaching my customer.rptdesign file here. When I click "Cust code" or "Name" header link in table, it shows error:

Error.ScriptClassCastError ( 8 time(s) ) detail : org.eclipse.birt.report.engine.api.EngineException: Class com.mindfire.birt.handler.CustomerHandler does not implement the org.eclipse.birt.report.engine.api.script.eventhandler.IScriptedDataSetEventHandler interface. (Element ID:71)

My handler class extends the "ScriptedDataSetEventAdapter". This error only occurs in my web application. The header link works when I preview my design in eclipse.

Please let me know what wrong I am doing.

Thanks - Pranav

4

0 回答 0