Vita Rara: A Life Uncommon

Quadran Update

Categories: | | | | |

This has been a very frustrating week. All in all I worked on working. I'm fried. I'm going for ice cream.

Got JBoss, Java Persistance API, Spring and Webwork Playing Nice

Over the past few weeks I've coded the data layer of Quadran using EJB3 (JPA) and making data access object that subclass from Springs JpaDaoSupport class. Coding all of this and getting it deployed on JBoss was fairly straight forward. The interesting part came when I tried to instantiate the DAO's from Spring and inject the EntityManager instance. That was fun. Stay tuned for a HOWTO in the near future.

I also got WebWork mixed into this all. That was actually quite easy. Getting JBoss and Spring to play nicely was the hard part.

WebWork / Struts 2

After examining a lot of frameworks I decided that we would start off with WebWork 2.2.2 with a planned move to Struts 2 as soon as there is a candidate release.

Once I got my first action injected with service object from Spring I actually needed to create a form. I wish I had examined this earlier as I'm not sure I would have gone with WebWork. I'm frankly unimpressed with the taglibs it provides, and I'm also starting to seriously question the whole value stack paradigm, and OGNL. It seems to make things that hard. Harder than they should be. I'm going to take a wait and see attitude on this. There were several things that attracted me to WebWork, many of which were also in Spring MVC. There is a possibility that I might bolt for the door and make a run for Spring MVC if my experience doesn't improve soon.

My main area of issue is with the UI components provided by the taglibs. They are an interesting study. Each tag is backed my a FreeMarker template. The issue I have is that the FreeMarker template can't communicate anything back to the calling tag. The tags have a default "theme" that lays out forms in a table with a td tag for the label and a td tag for the input element. So you have a two column layout. I simply wanted to extend that to a four column layout. It took me about two days to figure out how to do it. It was a little painful, but it works.

Here's the source of the JSP:

<ww:form theme="xhtml" namespace="/party" action="createParty.action" method="post">
    <ww:textfield label="First Name" name="party.firstName" />
    <ww:textfield label="Last Name/Organization Name" name="party.lastName" />
        <td colspan="1">Primary Contact</td>
        <td colspan="1">Leave name blank for individuals</td>
    <ww:textfield label="First Name" name="contactMechanism.firstName" />
    <ww:textfield label="Last Name" name="contactMechanism.lastName" />
    <ww:textfield label="Address 1" name="contactMechanism.address1" />
    <ww:textfield label="Address 2" name="contactMechanism.address2" />
    <ww:textfield label="City" name="" />
    <ww:textfield label="State" name="contactMechanism.state" />
    <ww:textfield label="Zip" name="" />
    <ww:textfield label="Country" name="" />
    <ww:select name="selectedPartyTypes" label="Party Types" size="5"
        list="partyTypes" listKey="id" listValue="description" multiple="true" />
    <ww:select name="selectedPartyRoles" label="Party Roles" size="5"
        list="partyRoleTypes" listKey="id" listValue="description"
        multiple="true" />
    <ww:submit value="Create Party" />

I like this. It's elegant. No table, tr, or td tags, unless you need to insert a header row.

This renders a form that looks like this:

It took two days to get to this:

That's just too damned long. It really makes me wonder if people are actually using this feature of WebWork. It seems so simple as to be unusable if you want to make any considerable changes. What if you wanted something more than two columns? What if you needed to have the label or input span columns. The offered solution is to use the "simple" theme which just leaves you writing your HTML table all on your own. This is what the book I read about WebWork says you can get away from. It seems far from it.

It's great that there is this backing template to the tags, but it's damned hard to work with.


Almost forgot, Elipse pretty much died on me. It ran out of memory and corrupted my workspace beyond recovery. As I posted previously it thinks my files are littered with errors. I've given up on it and have gone back to screen, vi, and ant. That was a lot of frustration. I need to stop working on working and get some work done.

That's it. I'm going for ice cream.