Vita Rara: A Life Uncommon


Mark's Struts 2 Cookbook

Categories: | |

Struts 2 is the new version of Struts, under development at the Apache Group. It is based on WebWork 2, and has many modern web framework features, like user interface tags, type conversion, and validation. Struts 2 is highly flexible and extensible.

In this cookbook you will find HOWTO guides, and recipes for common scenarios in Struts 2.

Updating a List of Domain Entities in Struts 2

Categories: | | |

I've been working on Quadran a lot, and I'm creating pages for editing lists of entities. The CRUD example from the Struts 2 Showcase application does this in a very simple manner. It recreates all of the entities every time you update the list. That's fine for an example but unusable in real life.

In real life we have to present entities from our database and then put the values back into the same entities, and update our database. We can't just re-create them.

The Entity

So, we'll start with a simple domain object and assume that we're using something like JPA or Hibernate to persist it via a Data Access Object (DAO), and that it contains a property called "id".

Don't Swallow Exceptions

Categories: |

Over the past two days I've been trouble shooting an application for a client. It's an old Java server application based on the Enhydra Framework and EJB 1.1. It's old.

I had most everything working but something in the system was throwing an exception that the code was swallowing and just display a page that said an exception had been thrown. No log message, no stack trace, nothing. Don't ever do this. If you don't have a system wide means of handling exceptions at least put in an e.printStackTrace(). It's the least you can do.

Eventually we had to go to the vendor, who no longer really supports the application, and have them add the e.printStackTrace() statement so we could debug the application. One line was all it took to fix the issue.

MacBook Pro Core 2 Duo

Categories: | |

I picked up a new MacBook Pro (MBP) Core 2 Duo on Friday. This is a replacement for my iBook G4 1.3GHz I purchased in the fall of '04. This is my third Apple laptop, and my first professional model. My other one was an iBook G3 700MHz model.

I spent most of Saturday moving into and getting comfortable with the MBP. This is my fourth OS X migration since switching to a Mac. All in all they have gone impressively well, and this one was just more of the same. Boot the Mac for the first time, hook the firewire cable to the old machine and wait. When it's done it's your machine, with all of your files, settings, applications, etc. Apple has really made the process of moving from machine to machine a painless exercise.

JBoss 4, EJB 3 Entities (JPA), and Spring

Categories: | | | | |

Over the last week or so I have been working on getting JBoss, JPA and Spring working together. When I wrote my previous entry I thought I had everything working. Well, up to that point I had not tried to save a record to the database. When I tried to do that nothing happened. This lead to a long debugging process that felt more like a hopeless goose chase at times. With the help of Costin Leau on the Spring forum I finally got it working, but it was quite the trial. Not many people have attempted to get this combination working. One of the things that complicated my setup is that my data access objects are a descendant of the JpaDaoSupport class provided in the Spring framework.

JBoss 4, JPA, @PrePersist and Primary Key Generation

Categories: | |

JBoss 4, JPA, @PrePersist and Primary Key Generation

In a past project I started using globally unique ID's (GUID) using XDoclet. I really like this methodology and planned on using it in Quadran.

So, I wrote my classes and was generating the ID's in the persist method of my data access objects (DAO). This didn't work very well, because when my persist would cascade the dependent objects did not have their ID's set, and Hibernate, which is JBoss uses to implement JPA, would throw an exception.

So, to work around this I started traversing the graph of objects in my business classes and setting the ID's before I handed them to the DAO's to be persisted. This was ugly, so I went in search of a better solution.

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.

Eclipse: Not so Stable

Categories: | |

My experiment with Eclipse isn't going very well. I did an upgrade to 3.2, which apparently hopelessly corrupted my workspace, or at least that's all I can conclude based on the evidence. I say that because I'm obviously not an Eclipse expert. My diagnosis is based on the fact that a deletion of the workspace and a re-import of the project I was working on from the file system fixed the issue.

Today, Eclipse ran out of memory and has somehow corrupted its environment such that the Java Editor is hopelessly confused, and has placed error warnings, x's, along in a seemingly random pattern in almost all of my files.

Frustrating Days in Quadran Land

Categories: | | | | | |

The past week or so has been one of frustration. It seems like I have been working on working. I've been setting up Spring, and WebWork, creating the skeleton of WebWork action classes. All in all a lot of busy work.

In the course of creating the JPA implementation of our data layer I used the JpaDaoSupport from the Spring framework. This caused some boot strapping issues when I went to get all of this running under JBoss 4.0.4.GA. The persistence archive deployed perfectly, but it was bear from that point out getting the DAO's to work. I think I have it figured out, and will post a HOWTO once I have it all working.

Mac OS X RSS Readers

Categories: | | |

I've decided that I need to make my web browsing and information collection more efficient in order to raise my level of productivity. I've been spending far too much time tracking websites of both professional and personal interest that I like. So, I decided it was time to check out RSS readers.

Additionally I've decided that there are a number of Blogs that I'd like to track that don't produce a lot of new content. Just a few articles per week at the most. It doesn't make sense to visit these sites every day, and I don't want to use something like Technorati. I really want to stay off sites that will get me browsing ad-hoc, and stay focused on the information I need to know about while ignoring the rest.

Syndicate content