Archive for the ‘Uncategorized’ Category

Java User Group Macedonia

I’ll be in Skopje (Macedonia capital) in 4 March speaking about Flex, Air and Java.

Code of the day

One of my friends just sent me a code sample and I thought it would be a good idea to share it. It’s taken from a real project and it was written by someone with the title of “Software architect”.

Code sample:

try{
    someObject.someMethodName();
}catch(NullPointerException e){
    throw new BusinessException("the object is null")
}

And no, it’s not a joke.

Javascript – notify users when leaving a page

A long time ago I had to modify a 100+ screens application in order to notify the user when leaving a page if some data from the page was modified. The screens were pretty complex and some fields were created or deleted from the DOM during the edit process. I wrote a general function to deal with that (at loading time it saves the page content and when trying to change/unload the page it was possible to compare the new data with the saved one). Two methods are available

Utils.storeData(<parent tage name>) //save data
Utils.pageModified(<parent tage name>) //returns true is the values were modified

The following HTML elements are watched for modifications:text, textarea, file, select-one, select-multiple, radio, hidden, password, checkbox. The code will detect if new HTML elements are added or removed from page.

You can download the JS class from here. If you find it useful you can use it or modify it as you want.

LCDS Data Management – Unable to access UserTransaction in DataService

I’m tired of receiving this error every time I create a Flex/Java project (using LCDS). The error appears because the JOTM is not properly configured (the full description can be found here). In my opinion the “New project wizard” for a LCDS-enabled project should automatically create the context.xml file and it should also check also if the Tomcat is properly configured (JOTM should exist in common/lib etc). It’s hard for someone just trying to learn LCDS to know these things from the beginning.