Monday, May 18, 2009

BIRT: Accessing the Report Context in Java Chart Event Handler

After Googling this, it seems that this is a common question that has no posted answers. seriously, thats annoying. I hate when that happens.

Anyway, so what I needed was to set a property in the report context that could be accessed withing a chart event. Now, if I was using the Javascript handler, something like the following would be sufficient:
context.getExternalContext().getScriptable()

However, this does not return anything close to a context in a Java event handler. The
context.getExternalContext() returns a BIRTExternalContext object, this is not a public accessible class. And getScriptable
returns a NativeJavaObject. So, in a way that is not documented anywhere, you can do the
following to get access to an IReportContext object from within a Java Event handler for charts:

Object o = icsc.getExternalContext().getObject();
IReportContext context = (IReportContext)o;

Thats it. Not sure why this is not documented anywhere since it seems to be asked a bunch.

Saturday, May 09, 2009

Electronics: Goodwill is an Electronics Goldmine

Seriously. Especially old, outdated stuff. And if your looking for wall warts, you just can't beat Goodwill. We went in there looking for 80's cloths for a theme party, I walked out with 3 9 volt, 500 mA wall warts for less than 3 bucks. Cheapest I could find them online was about 3 bucks a piece. Radio Shack sells them for about 20 bucks. I'm sure everyone who is an electronics tinkerer already knew this, and I'd heard it years ago, but I was blown away. Worth keeping in mind for the microcontroller projects.