Skip to main content



      Home
Home » Archived » BIRT » More instance of IImageEventHandler
More instance of IImageEventHandler [message #1073690] Thu, 25 July 2013 06:09 Go to next message
Eclipse UserFriend
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 #1073795 is a reply to message #1073690] Thu, 25 July 2013 09:51 Go to previous messageGo to next message
Eclipse UserFriend
I can see this behavior also when running 'runAndRender' task. So it's a problem of a concrete report.
Other reports (also with image and that handler), creates only one instance.

What am I missing here??
Re: More instance of IImageEventHandler [message #1075653 is a reply to message #1073795] Mon, 29 July 2013 16:33 Go to previous messageGo to next message
Eclipse UserFriend
In the other reports where you only see one instance, do you use the handler in both script methods? Or just one?
Re: More instance of IImageEventHandler [message #1075849 is a reply to message #1075653] Tue, 30 July 2013 03:37 Go to previous message
Eclipse UserFriend
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).
Previous Topic:Populate report parameter based on another parameters selection
Next Topic:change date parameter value from script
Goto Forum:
  


Current Time: Sat Jul 12 06:46:46 EDT 2025

Powered by FUDForum. Page generated in 0.03768 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top