Your FLEXible friend
For the last 3 months I have been using Adobe FLEX to develop a front end for the Obesity eLab. Now, I don’t want to get into discussions about the rights and wrongs of RIAs etc. but just thought I would pass on a few interesting FLEX/Flash/Actionscript things I have found out during this coding voyage.
- Remember your Cross Domain policy or your client will not be able to talk to your server
- When adding custom MXML modules programatically there is no guarantee that any of the components inside will exist. Can lead to lots of annoying null pointer exceptions. You might have to check that they are not null and create them in actionscript. I have found that doing something with the parent module eg. adding to a tab navigator forced the child components into life. Setting the creationPolicy to ALL seems to have no affect. I look forward to finding out the correct way to do this because I have found little to help on the web.
- When downloading files using FileReference you have to add an event listener to handle the IOErrorEvent.IO_ERROR or else you get a #2038 IO Error
- To add an icon to a button that has been created in ActioScript you have to declare the icon you want to use like this:
- [Embed(source=’/assets/analysis_small.png’)]
[Bindable]
private var analysisImage:Class; - Assign using code: analysisButton.setStyle(”icon”, analysisImage);
- Events seem to pass from child to parent but not the other way. When adding event listeners you need to add them to the level above the originator of the event. Has meant all sorts of weird things like systemManager.addEventListener and Application.application.addEventListener. Now, I might be getting this wrong but no amount of googling has led to a sensible answer.
Overall, FLEX seems great for UIs which are not reacting to data changes but needs a bit of tweeking by Adobe to make it a real power users language of choice. Doing things like grids which react to check box clicks needs quite a bit of code. There also seems to be some fundamental UI components missing eg. dockable drag and drop panels. Sure, there is usually some open source solution available or you can write your own but it would be nice if the core API had these things.
Statistically speaking
We have been investigating data requirements for the Obesity e-Lab project recently. This required some analysis of data created by the stata stats package. However, we had to read it using the R tool instead (firstly because we can then use Taverna workflows to execute R scripts and secondly because Stata is not free). After some head scratching we figured out that you had to use the ‘foreign’ library and the read.dta function. This mean turning on the foreign library in the Package Manager using the R gui first and then executing the following command:
read.dta(”filename”, convert.dates = TRUE, tz = NULL, convert.factors = TRUE, missing.type = FALSE, convert.underscore=TRUE, warn.missing.labels=TRUE)
Remote control debugging
If you are developing in java with eclipse then add this to the start up script of any apps you are developing -Xrunjdwp:transport=dt_socket,suspend=n,server=y,address=8993
You can then connect to them remotely using the Remote Java Application debug configuration in eclipse. You can then use the eclipse debugger to step through any tricky code.
The application will start with “Listening for transport dt_socket at address: 8993″ and you connect to it through this port. Inside eclipse you can add any jars, local projects etc. to the debugger as it steps into new classes and you can then view the code (and the application) as it runs.
Hellllloooooooo, where are you RESTLet
We are currently developing a little REST based service for the storage of RDF. It uses openAnzo (2.5.1) and Restlet (1.0.5). All was going well until the client calls disappeared into a black hole. No responses were coming back from the server, in fact nothing seemed to be arriving there. Turns out that when you get a Response back from Restlet it has a stream which it would like you to either read or close, for example:
response.getEntity().getStream().close();
or
response.getEntity().write(System.out);
Otherwise the client keeps trying to send to the server but can’t get an open socket to get there. Another problem solved!
Cross platform fun
While debugging some test problems with the T2 code I discovered some issues between OSX and Windows regards file paths and line breaks. Seems that instead of just
inputs.put(”fileUrl”, LocalworkerTranslator.class.getResource( “/AAC4_HUMAN.sp”).getFile());
you have to ensure that the absolute path is correct by doing
URI uri = LocalworkerTranslator.class.getResource(”/AAC4_HUMAN.sp”) .toURI();
File newFile = new File(uri);
inputs.put(”fileUrl”, newFile.getAbsolutePath());
Also, you can’t expect checks for “\n” style line breaks to work in Windows because they insert things like “\r\n” instead. So , you should use System.getProperty(”line.separator”) instead.


