Tuesday, February 17, 2009

Seambay modifications to access Seam Annotations

This post extends my last one about accessing Seam from the command line. Here I describe the transition from using EntityManager to using EntityHome.

The first thing I did was to create a new folder for the webSevice sources, which meant that I had to add this directory into the build.xml file and add all of the libraries into the compile path in NetBeans (both of which are obvious, but both of which I always forget to do).

The next was to make my action work similarly to an .xhtml page and interact with a home object rather than directly with the EntityManager
going from:

      
if (fileData == null) {
fileData = new FileData();
// various actions on fileData
entityManager.persist(fileData);
}

to
       
if (fileData == null) {
fileDataHome.create();
fileDataHome.persist(); //side effect of creating the defined instance
fileData = fileDataHome.getDefinedInstance();
// various actions on fileData
fileDataHome.update();
}


which also required adding these lines to components.xml

xmlns:transaction=”http://jboss.com/products/seam/transaction”   
....
<transaction:ejb-transaction/>


None of which was particularly difficult and I was up and running in a hour or so.

No comments: