Vita Rara: A Life Uncommon

Look Ma' No Semi-Colons!


Categories:

I was working on a script today. I've been working on converting a lot of Perl scripts to Groovy over the past week. Anyway, I just removed all of the semi-colons from a script to see what it looks like. I like it. It makes it look different than Java. Try it. You might think the same.

Gettin' Groovy With It


Categories: | | |

Well, this week after hearing about Groovy and reading a bit about it I decided to take the plunge. I've grown tired of the get's and set's in Java code. It's all boiler plate repetitive, non-expressive junk. I've been listening to the Java Posse for quite some time, and all the talk about language level support of properties got to me. I checked out the Grooy Beans page and was sold.

As a proof of concept I started out writing some integration tests first. I used that as the test bed to get Groovy working with Maven. (I'll write more about that later.) Once I had that done I converted a Struts 2 Action that employed an Action class, a Model and a Query bean (to store the users input) into a single clear concise Groovy class. Three classes became one, rose in readability and it was quick. My Action, Model and Query class had a total of about 40 setters and getters. They're all gone now.

Maven Jetty Plugin Logging Woes


Categories: | | |

My logging issues weren't completely over yesterday. I first adopted the "org.apache.commons.logging.impl.SimpleLog" method in the Jetty plugin, but this still spewed far too many lines of logging in my Struts 2 application. The major culprit was FreeMarker. It logs a tremendous amount of data. Far more than I would ever think the average non-FreeMarker developer would ever need.

So, I decided I needed to go the log4j route, so I could control the levels for the various libraries. I copied the dependencies section as explained on the jetty page. This lead to errors when parsing JSP pages and tags. Something in those dependencies introduced something strange into the Jetty runtime environment. After futzing about for a while, and sleeping on it I decided to just delete the dependencies and still try to use log4j. Lo and behold it worked. I started with the log4j.properties file in /src/main/resources created by the Struts 2 Maven archetype as my starting point, and now I have a finely tuned log4j setup.

Web Page Data Models: Where do they go?


Categories: | |

You have a web page that has tabular data that doesn't represent simple rows from a database. It's a field from this table, one from that, one from four joins away. It's a little bit of data from all over your data model, but the client wants it on the screen. What do you do?

In the past I used to just a SQL result set and turn it into a Collection. Nice and neat. Iterate over the collection and put the stuff onto the screen. Simple enough, back then. Now I'd like to have better control over my models, and have them be full classes, with strong typing, setters and getters, etc.

The question is where should that class reside? Is it part of the data model? Is it a business object? It's really a presentation model. It only exists to make presentation of data easier. In essence it's like a report, or an element of a report. So, where should it live?

Maven Jetty Plugin Logging


Categories: | | |

I've gotten Maven, Jetty, Spring, and JPA playing well together! I've ecstatic. Bye, bye JBoss. I don't know that I'll never run JBoss for development again, but I don't think it will be common.

Anyway, upon getting the Jetty Maven Plugin working (mvn jetty:run) it was logging too much debug information. Hitting one page ran out a 10,000 line buffer on my terminal. There was a simple quick fix though. Add a few properties to the plugin configuration in your POM file and voila, reasonable logging.

Kicking the JBoss Habit: JBoss, JPA and Spring? Or Spring and JPA?


Categories: | | | | | | |

Hi, my name's Mark and I'm a JBoss user.

Ok now everyone.... "Hi Mark."

I have been a JBoss user for many many years. It all started with the seductive siren of Enterprise Java Beans. I still have a deployed application running on 2.4.3, or something like that. (Behind a firewall, thank heavens.) Well, today I took a few more solid steps toward kicking the JBoss habit.

If you've followed this blog you'll remember that I'm working on an ERP application for a client, Quadran. Yesterday I fought with query issues and JSP reloads for hours. With JBoss it's compile, package, re-deploy, wait. Change a few characters, compile, package, re-deploy and wait! It finally got to me.

UnRally VI: Fayetteville, West Virginia - September 4-6, 2007


Categories: | | |

Sylva and I are going to be the UnOrganizers for the Annual BMWSportTouring.com UnRally. This is a annual get together of BMW motorcycle sport touring enthusiasts and others. (You don't need to ride a BMW.)

To follow our progress on this project you can check out the UnRally planning forum on BMWST.com.

New Server - A Little Xen


Categories: |

The past week has been a trial by fire. We purchased a new server to handle hosting sites, email, clients, etc. Dual quad core Xeon, 16GB RAM and lots of drive space. This machine was too much to waste on a single installation of Linux so I decided it was time to learn virtualization and Xen in particular.

Xen is a hypervisor that makes it possible to run multiple operating systems on one machine as though it were multiple machines. Basically it allows you to make one computer look like a whole bunch of computers. Each "computer" can even run a different operating system.

Creating a UI Component in Struts 2


Categories: | |

Problem

You have a form "element" that consists of several HTML actual elements. You'd like to create these using one Struts 2 UI tag, rather then write the HTML out everywhere it's needed.

Background

The Struts 2 UI tag library provide a component tag, which can be used to create your own "tags" without needing to dive into the JSP tag library API. Creating a tag using the Struts 2 component tag, also allows it to directly take advantage of the Struts 2 framework, such as OGNL support, and the existing Struts 2 UI tag themes.

Recipe

In this recipe we will creating an HTML control using the component tag that will display two input fields. This is a simple example, but it will show the process of creating a component, and tying it into the existing Struts 2 Xhtml theme.

Creating a Theme in Struts 2


Categories: |

Struts 2 has a very powerful set of user interface tags (UI Tags). These tags are tightly integrated with the framework, taking full advantage of things like the OGNL Value Stack. The power this gives to a user it tremendous.

Struts 2 UI Tags

The Struts 2 UI Tags are backed with templates that do the actual rendering of HTML. You can change them without any need to touch the implementing classes. As of Struts 2.0.2 these templates are written in the FreeMarker template language. A quick look at the Freemarker Manual will provide you a quick overview of the language, and is helpful if you have questions about the language. Anyone familiar with JSP, PHP, or other template languages can quickly grasp it.