More instance of IImageEventHandler [message #1073690] |
Thu, 25 July 2013 06:09  |
Eclipse User |
|
|
|
I have an image element within my report with an element handler where I do some logic in its onPrepare and onCreate methods.
When I generate the report using 'runAndRender' task, the handler instance is created only once. But when I just run the 'run' task, the handler is instantiated once for each method - so there are two instances.
Is this expected behavior? My handler is stateful, so it breaks my report.
I have set 'New handler on each event' to false. My Birt version is 3.7.2.
|
|
|
|
|
Re: More instance of IImageEventHandler [message #1075849 is a reply to message #1075653] |
Tue, 30 July 2013 03:37  |
Eclipse User |
|
|
|
I use the same handler in all reports:
public class SplmageEventHandler extends ImageEventAdapter {
private String columnName;
@Override
public void onPrepare(IImage imageHandle, IReportContext reportContext) throws ScriptException {
columnName = StringUtils.substringBetween(StringUtils.substringBetween(imageHandle.getValueExpression(), "[", "]"), "\"", "\"");
}
@Override
public void onCreate(IImageInstance image, IReportContext reportContext) throws ScriptException {
final Object data = image.getRowData().getColumnValue(getColumnName());
if (data != null) {
...
if (...) {
image.setMimeType("image/svg+xml");
}
}
}
public String getColumnName() {
return columnName;
}
}
Basically it sets mime type based on the passed data type. I just need onPrepare to get column binding name (the handler is general and is used for every dynamic image in my reports).
|
|
|
Powered by
FUDForum. Page generated in 0.03768 seconds