Friday, September 08, 2006


'ListOfFiles' ant task

Here is an ant task, that converts ant FileSet into property containing string with list of files. I have used that task many times in my ant scripts. Most useful use cases include building "Class-Path:" manifest attribute and list of files for compc Flex 2 compiler.

It can be used in many other places where you need to convert fileset into a string of comma or space separated files.

You can download source and jar for this task at

Here is an example on how to use it:

<project …

<taskdef name="list-of-files" class="com.igorgrapp.taskdefs.ListOfFilesTask">
<pathelement location="ant-igrapp.jar"/>


<target …

<list-of-files separator=" " outProperty="libs" prefix="../lib">
<fileset dir="${basedir}/lib">
<include name="**/*.jar"/>

<jar destfile="some.jar">
<attribute name="Class-Path" value="${libs}">

For more examples download zip file and check out test.xml

There are number of utilities that need to be run during project build process and require to pass files as list of comma or space separated arguments.

Tuesday, September 05, 2006


Link JSP Tag

Link tag is a tag that is similar to "html:struts" tag, but render an "link tag rather "a" tag.

Basically code is very straightforward, and most complicated chunk is on lines 112-125 - rendering static html attributes was placed there out of my laziness - I did not want to cut-n-paste all these attributes.

Anyway, I found it very useful for rendering context independent css link tags in the header of the html page.

Download source here

Friday, September 01, 2006


Flex for Java Prgrammers

I discover a very interesting Flex 2 feature today:

You MUST explicitly import all classes used in your program, even if you specify full class name ( including package )

This WILL NOT work:

public var myclass: com.package.MyClass;

This WILL work:
import com.package.MyClass;
public var myclass: com.package.MyClass;

Weird, but true....

Saturday, August 26, 2006


SVN and CVS eclipse plugins.

Today I have used SVN for the first time and I got mixed feeling about SVN plugin for Eclipse.

Overwall it works ok , however there were couple of things that confused me.

A lot of people claim SVN to be faster, but I really did not feel it. To me it seemed to have no better performance than CVS.

Many times, when integrating other people changes to CVS, I just place updated file over existing and commit. When I tried to do that using eclipse SNV plugin, it marked file as deleted. I needed to open file and use cut-n-paste to replace its content. Seems a little weird to me and CVS is much straightforward in this.

SVN has file locking - this is a good thing, becuase many tims you need to lock a file while working on it and merge really complicate things, rather solves issues. Developers suppose to talk one with each other about changes, but it does not work at times.

My final conclusion that I will need to think if I really want to use SVN instead of CVS.

Wednesday, August 23, 2006


Struts error message handling

There is a lot of material written on how to handle error messages with struts, but I would like outline implementation for specific use case that I had to implement today.

There is a form that does some work Once user submit the form, action performed and user redirected back to the initial page with form, displaying either error message in red color or success message in green color.
Message should be displayed only once, and subsequent refresh of the page should not display neither success or error message. No ".do" url should ever appear in address bar

Create "success" and "error" message bundles and use 2 different instances of tag to control presentation. Make sure that in the action code either "success" or "error" resources keys are passed, not both. Errors then saved on the session, in order to survive http redirect. jsp page has logic for transering error o

Important Implementation points:
Implementation Steps

1. Create
uc1_struts_error.success=This is a success

2. Create
uc1_struts_error.error=This is error

Configure and in struts-config.xml
Add entries below to the struts-config.xml
<message-resources parameter="com.igrapp.u1_strutserror.ErrorResources" key="errorBundle" />
<message-resources parameter="com.igrapp.u1_strutserror.SuccessResources" key="successBundle"/>

4. Code action.
DynaActionForm f = (DynaActionForm)form;
ActionMessages msg = new ActionMessages();

String test = f.getString("test");
if ( test == null || test.trim().length() == 0 ) {
msg.add(null, new ActionMessage( "uc1_struts_error.error"));
} else {
msg.add(null, new ActionMessage( "uc1_struts_error.success"));


saveErrors(req.getSession(), msg);
return mapping.findForward("success");

4. Add action and DynaForm into struts-config.xml
<form-bean name="MyForm"
<form-property name="test" type="java.lang.String"/>

Add code to jsp page.
Object o = session.getAttribute( "org.apache.struts.action.ERROR");
if ( o != null ) {
request.setAttribute( "org.apache.struts.action.ERROR", o);
session.removeAttribute( "org.apache.struts.action.ERROR");

<font color="red"><html:errors bundle="errorBundle"/></font>
<font color="green"><html:errors bundle="successBundle" />

Download source archive from my personal web site at

Saturday, August 19, 2006 in JavaMail API

Today I discovered that java has a limited way of handling encodings in java mail API and I guess that goes for working with text in general.

my problem was that during call to POP3Message.getContent() or call to Part.getContent() was thrown.

According to JavaMail FAQ answer you should catch UnsupportedEncodingException and handle it by "choose a charset in some heruistic manner".

One of the encodings I had a problem with was "x-mac-cyrrilic". It actually was located in $JRE/lib/charsets.jar as "x-MacCyrillic". I discovered it looking at supproted encodings list located at for JDK15.

I wonder if all encodings are there and what to do if there is a need to handle message with encodings that is not supported.

For nio there is a java.nio.charset.spi.CharsetProvider class that could be used.

Friday, August 18, 2006


Spring IDE experience

Today I decided to install Spring IDE.

I point my eclipse update manager to and install went smothly.

It took a little time to figure out that how to use it, but after reading manual everyting was worked ot just fine. ( or course I am too lazy to read it first ).

I consider it pretty useful for creating configuration files. Most useful feature is validation - it found couple of unexpected typos in context files.

Overall install went pretty smoothly and it added to overwall process.


Flex RealWord seminar

Attended Flex RealWorld seminar.

Primarely there were 2 interestng presentations:
- DaoFlex by presented by Victor Rasputinis and Yakov Fain. This is very cool code generator allows automate tidious tasks of mass code creation. And even though the idea is not new it is still very actual in real life projects. Unlike other toold it allows you to call Database and generate code based on metadata it can grab during DB call.

- Mapping mashups presented by Mansour Raad from ESRI. This application shows power of applications and on the other end represent cutting edge technology. Even though thereare many other apps, but Flex power is clearly shown.

I got surprised how many people were using ColdFusion. I had an impression that this product is dead, but apparently it is not.

This page is powered by Blogger. Isn't yours?