jump to navigation

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.


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.

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.

Enterprise Swing Best Practices August 6, 2009

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

I know this blog is about J2EE, i.e. enterprise Java on the server side. But the past few months I’ve been working on an “enterprise” Swing-based desktop application. I say “enterprise” because it’s virtually the same as a server-side application – the only difference is that it’s using Swing for the presentation layer.

Anyway, I wanted to post up some of the things I’ve discovered: Swing is very easy, but it seems there aren’t many “best practice” guides for building an application using it. So, here is my list of “best practices”… hope you find it interesting!

  • The Presentation Model pattern is well worth using. It creates a much more loosely coupled dependency between the GUI code and the presentation logic.
  • On a similar note, using a binding framework (such as JGoodies Binding).
  • Use Actions (i.e. subclass javax.swing.AbstractAction) for use with menus and buttons etc.
  • For laying out forms, JGoodies Forms is awesome.
  • There are benefits to using component factories, i.e. a factory method to create your different UI components such as buttons.

I think that’s about it for the moment. The only other thing is, the Spring Rich Client Project (Spring RCP) looks really interesting, and I think if I was starting a new project I’d probably use it.

What are your favourite Swing tips?

Creating a lazy-loading tree with IceFaces July 7, 2008

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

I tried a number of things to make a lazy-loaded tree in IceFaces, but I couldn’t quite get it to work. There are probably better ways of doing it, but I found something which is pretty easy: when you create your lazy-loaded TreeNodes, for each node which hasn’t had its children loaded yet just create a dummy child. In other words, if you don’t want a node to be lazy-loaded, just add a TreeNode child in which says something like “Loading…”. You will also need to subclass DefaultMutableTreeNode to add in a boolean property – something like childrenLoaded.

Then, in your JSF page, set the tree actionListener property to be “#{beanName.expandListener}” and create the relevant method in your backing bean:

public void expand( ActionEvent e )
        Tree tree = (Tree) e.getSource();

        TreeNode node = tree.getNavigatedNode();
        if ("expand".equals( tree.getNavigationEventType() ))
            _treeModel.loadChildren( node );

… assuming, of course, that your TreeModel has a “loadChildren” method on it. Your mileage may vary. You will, of course, need to check whether the children have already been loaded for that node. But it’s still probably the easiest method that I’ve found so far!

Caching using WebLogic tags July 19, 2007

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

We’ve been having a random issue with JSP fragments recently: on one of our applications, the page layout components are divided into JSP fragments. Each JSP fragment pulls in the actual content from a page on our client’s server (so they can easily update it). It works like this:

The main page includes a component, say, leftnav.jsp: <jsp:include page="leftnav.jsp" />

leftnav.jsp looks a bit like this:

<wl:cache timeout="15m" async="true">
<io:http url="http://url/page.html" action="GET" />

The problem we’ve been having is that sometimes, the body content appears in the left-hand navigation bar, and the left-hand navigation gets displayed twice! I think we’ve basically narrowed it down to the caching. According to WebLogic’s documentation, the cache JSP tag by default uses the page URI as the cache key. If you have multiple cache elements in a page (which the leftnav.jsp does have) I think this could cause a problem.

What we have done so far is give each cache tag element a distinct name, and the problem hasn’t occured again … yet! It’s difficult to track down because it’s quite erratic.

Hopefully that will solve the problem — if not, I will have to update again soon 😉