jump to navigation

Blog Closing August 21, 2012

Posted by Phill in General J2EE.
comments closed

Sadly, this blog is now closed. I have essentially changed career – I am no longer working in software development.

I will leave this blog here for future reference if necessary, unfortunately the information is going to become more and more out of date as I won’t be updating it any more!


IE and Column Widths March 8, 2011

Posted by Phill in Presentation Layer.
Tags: , , , , , ,
comments closed

Uh… hi. It’s been a looooong time since I last wrote here. I’m sorry. I’ve been very busy on a project which uses GWT and Smart GWT. We’ve come across a lot of problems, some of which I hope to blog about.

But what I want to talk about today is something pretty simple: Internet Explorer and column widths. We’ve written a custom component which replaces Smart GWT’s ListGrid – essentially it uses a standard HTML table instead of using DIVs.

Part of the issue we were having is that the column widths were essentially being ignored: IE was just drawing all the columns as equal width. (The CSS on the TABLE element was set as table-layout: fixed).

We were using the HTML COL tag to set the width for each column – all this was added in dynamically via GWT.

As it turns out, the reason IE was ignoring this was because you need to add it to a COLGROUP first. If you add in a COLGROUP, and then add the COL elements to that group, it works.

Spring Aggregating MessageSource March 26, 2010

Posted by Phill in General J2EE, Spring.
Tags: , , ,
comments closed

If you’ve ever worked on a modular project which needs to be internationalised, chances are you’ll have run into the requirement of combining messages from various different modules.

By that I mean, each module has its own message source, but you want them to be combined into one MessageSource. This could be required for various different reasons which I won’t go into here, but suffice it to say that this is possible with Spring.

I created an AggregatingMessageSource which would scan the ApplicationContext for instances of MessageSource. When a message was requested, it would search each one sequentially for the relevant message.

Anyway, if you need such a class, I have uploaded it to get you started. Obviously, customise it to your own needs: AggregatingMessageSource.java.

Fun with Spring, GWT and Annotations March 4, 2010

Posted by Phill in Frameworks, Spring.
Tags: , , , ,
comments closed

Recently I’ve been porting across some of our monolithic IceFaces application to a more modular GWT application. (There’s nothing wrong with IceFaces as such, but for several reasons I don’t think it’s the right fit for us any more).

It’s been going pretty well so far, although I’ve only been working on it for a few days. I’ve got the GWT-Widget server library up and running as well, which integrates nicely with Spring for RPC. (It basically means you don’t have to define a new servlet in web.xml for each RPC server you want, you can just define them as Spring beans).

However, it does mean that you have to create a mapping for each Spring bean that you want to publish and define it in the application context XML, which isn’t really ideal for modular applications: I’d quite like them to be detected automatically with annotations, that way if you have another module on the classpath it will automatically be picked up.

So, I created another annotation (@RPCService) and annotated my RPC endpoints with it. The annotation, as its value, had the URL of that endpoint (i.e. “/user” for the users RPC service)

Then, my initial thought was to use Spring to scan the classpath and load each one up. I’ll cut a long story short here and say that was all unecessary: if your RPC classes are defined in the application context (via XML or annotations, it doesn’t matter), all you need to do is get an instance of the Application Context and call getBeansWithAnnotation.

This makes things really simple: I have a bean set up which has an initialise method that uses that method to get all classes annotated with my RPCService annotation, finds out their URLs, and then configures the GWTHandler servlet to map those beans.

Dead easy! And very useful to do, if you’re using the GWT-Widgets library.

Edit: After reading the documentation it seems that what I’ve done is essentially re-implement what’s already available in the library. Still, hopefully it will come in useful if you need to do something similar for another usage…

JSF, Float, and f:convertNumber February 16, 2010

Posted by Phill in Frameworks, Presentation Layer.
Tags: , , ,
comments closed

I’ve been having some fun issues with JSF and converting Float issues. Essentially the problem occured when converting a primitive float type to a java.lang.Float type in my value object (I was trying to updating a float value from an inputText field). I kept getting errors like:

java.lang.IllegalArgumentException: argument type mismatch

Anyway, I found an answer which seems to work, but rather than post it directly here I’ll simply link to the original question on StackOverflow (in case someone posts a better answer subsequently!).

These kind of issues are one of the many reasons why JSF has gone down in my estimation… it’s not a bad framework, it just seems to make what should be simple things massively complicated! That said, JSF 2.0 looks good, so maybe it will solve these kind of issues.

SSIS, C#, and Class Libraries February 4, 2010

Posted by Phill in Other Stuff.
Tags: , , , ,
comments closed

The past couple of weeks I’ve not been working in Java, I’ve actually been using SQL Server Integration Services. We are in the process of converting an old C++ based application to Java, with a SQL Server backend. Some of the old export processes that were previously written in C++ we have decided to re-write using SSIS.

I won’t bore you with the details, but I do want to blog about the way C# is used in SSIS. You can create ‘Script Tasks’ which basically run a piece of code for you. You can write it in VB.NET or C#.

Due to the particular export I was running, a lot of the logic needed to go into the C# code. The issue is, SSIS doesn’t make it easy for you to re-use code: essentially, when you create a script task you are creating a whole new C# project. This isn’t good.

What I did (after taking some advice from Stack Overflow), is create a class library. Being new to SSIS and the world of C# in general, I had to do a fair bit of trial and error to get it working. The best tutorial I found was here. Those steps were enough to get me started.

There are a few other things to mention as well:

  • For some reason, SSIS 2008 seems to be stuck in the world of .NET 2.0. I don’t know why, but that is why you have to copy the .dll to the .NET 2.x folder. You will probably also need to set the project properties (of your class library project) to .NET 2.0.
  • There seem to be two different ways of accessing SSIS variables from within a script, depending on whether your script is part of a Data Flow Task or not. If it’s part of a Data Flow Task, you access them via the ‘Variables’ member – easy enough. (Although remember to set them up as read-only or read-write variables in the task properties first). If your script task isn’t part of a data flow task, you will need to use the Dts variable. This confused me at first!
  • For some reason, rebuilding the Class Library package in Visual Studio seems to mean the Script Tasks using it also need to be recompiled. Update: I’ve found out why – if the version increments, you will need to rebuild the dependent projects. To stop this, you just need to set the class library version to be constant. This was actually the default in my project, but I’d changed it! You can do it from project properties -> Application -> Assembly Information dialog.

In general, it’s been a learning experience – worth doing though! I will hopefully update a bit more when I’ve had a chance to use it more…

MyEclipse and NullPointerExceptions December 3, 2009

Posted by Phill in Other Stuff.
Tags: , ,
comments closed

Quick one this time round. If you are using the MyEclipse editor for JSF / HTML files (in my case the MyEclipse HTML editor) and a dialog keeps popping up: “java.lang.NullPointerException. See error log for more details”, you may wish to refresh your workspace.

I kept getting this error and it turns out it was a problem with my workspace not being in sync with the files on disk. A refresh did the trck. I don’t know why this results in a NullPointerException, but there you go!

Spot the bug… October 28, 2009

Posted by Phill in Other Stuff.
Tags: , ,
comments closed

Have you ever written something really stupid but not noticed it for ages?

Witness this statement of mine I wrote a month or so ago. The point of the code is to append a prefix to an existing description, or the empty string if the description is null.

description = prefix + " " + description == null ? "" : description;

Can you spot the error?

It turns out that Java was looking at this statement like this:

description = (prefix + " " + description) == null ? "" : description;

D’oh! Not what I intended! I changed the statement to put brackets round the description == null ternary statement and it seems to work.

Just goes to show, brackets are generally a good idea when making statements like this – it’s too easy to make mistakes with operator precedence otherwise!

JAI October 19, 2009

Posted by Phill in General J2EE.
Tags: ,
comments closed

Recently I had a project where I needed to use Java Advanced Imaging (JAI) to convert TIFF files into JPG. (Unfortunately Java doesn’t provide a TIFF decoder out of the box).

I had an issue today whereby I needed to deploy the application on a server (it’s a web app). I kept coming up with errors about JAI not being able to find the TIFF decoder:

     at javax.imageio.spi.FilterIterator.next(Unknown Source)

For anyone who is Googling it!

Anyway, it turns out that I had got jai_core.jar and jai_codec.jar in my WEB-INF/lib folder (these are both part of the standard JAI Distribution), but for some reason I also needed jai_imageio.jar (which is part of the JAI-ImageIO package).

I can’t quite fathom why you need so many JAR files, but it seems to work now, so there you go. Hope this helps someone else out!

Wicket September 17, 2009

Posted by Phill in Frameworks, General J2EE, Presentation Layer.
Tags: ,
comments closed

The past few days I’ve been prototyping for a new project we’re starting up at work. Previous web projects we’ve done have mainly been using JSF, however for this project I’ve been looking into Apache Wicket.

My first impressions are, I like it. I like it a lot, in fact. It seems to achieve a much more clean separation between code / components and HTML than other frameworks do. It does take a while to get your head around it though – I’ve only been working with it for a few days so am still finding my way round!

But I expect I will blog up some info when I’ve got my head around it.