Today I was experimenting with maven. I wanted to add code coverage. Ofcourse I start thinking about cobertura immediately. So I dived into cobertura and maven integration. It became kind of an experience. I know a lot more about maven now. I have to figure out some stuff, but for now it is good enough. This entry gives some steps to help you get up to speed with cobertura.
1. Install maven 2 quick start guide maven
2. Create an application that knows how to handle the goals package and site.
see the quick start guide
3. The fun part begins : compile and install your own cobertura plugin.
Download the sources from the codehaus subversion repository. You can use the following url to download them anonymously with a tool like tortoisesvn
Then you have the sources. Now you need to alter the pom of that project to be able to check for latest versions. See the guide on the plugins website.
Issue the following command for the cobertura-maven-plugin project you have just downloaded and altered.
Now you are ready for the next step
4. Configure the pom.xml of your project to create the cobertura report.
There are two aspects, first you need to add the plugin to the build part, then to the reports part. See the usage page of the plugin home page
5. Run the site goal and start browsing your coverage files.
This is where I am having problems, it does work but you must do some parts alone. First I will give you what works, then I will give you what I am having problems with.
mvn clean package cobertura:cobertura
The first thing that gives problems is doing the code coverage on the top project that does not have sources itself. An error due to the fact that target/classes is missing is thrown. The second problem I have is that I cannot do the two commands at once, there is a class loading issue.
I want to emphasize that this is a beginners perspective. The issues I am having might not be the complete truth. If you now more, or if I find out more, I will revise this part.
This is the second book about ajax that I have read. And what a book it is. If you want to go into the depth of ajax this is the book you want. Within this review I will explain why.
This book is devided into four parts: Rethinking the web application
Discusse the more advanced Professional ajax side. Now we are learning about security, usability and performance. Also very interesting stuff Ajax by example
Interesting if you want to learn how it really works, I'dd rather use an existing library, but it is fun to learn.
So this is a great book, with real live examples and a very wide coverage of the subject.
Yesterday I had an issue with some of the xml validations. We all know those DTD definitions in an xml document where the dtd is on the internet. We do want to use xml validation via the dtd but the dtd cannot be found if you are not on the internet. How can we resolves this?
<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN//EN"
How can you add this dtd to eclipse?
Open the Preferences window of eclipse and go to:
MyEclipse > Editors > XML > XML Catalog
Now we need to add a user catalog. Push the new button.
Browse to the dtd (you can import it into your workspace at the same time. As a key enter the part after PUBLIC. -//SPRING/DTD BEAN//EN
There you have it, code completion in your xml editor.
A few years ago I was using the DisplayTag library, a very nice library I must add. When doing some coding for a project I had to many records to be in the table. Therefore I used the pagination, that is the moment I ran into problems. I wanted to do the paginations via the hibernate dataaccess layer. The current DisplayTag library does not support that. There are some samples with the HEAD version, I could not get the building process with maven to work. Therefore I started to look around and found a very nice component:
This library includes a very nice view, good paginations backed by server components you can easily write yourself. Therefore I am writing this item, just to show you all how easy it is to do pagination and filtering of your objects in a nicely formatted table.
Actually, I think this is a lot of code, so let's step through it. Lines 9-11 take care of using an external pagination, filtering and sorting. The LimitCallback is used for that purpose. Line 8 shows you the name that can be used as the current item. Have a look at line 19, here you can see we use the order property to obtain the current value for the field order.id. Other interesting stuff, you can switch off filtering and sorting for each column, you can easily format a date field, and you can create your own cell formatters as well. Line 22 shows you how to define them in the jsp. We will show you the code for the formatter as well. But first we'll show you the spring controller that calls the appropriate service.
The Jakarta Bean-Utils package is used to set the values from the filters into the object that is send to the search service. If you enter a value in the lastname box, the searchOrder object will receive this value for lastname so that you can use it in your data access component. The next part of source code does something simular for the ordering.
We created a special object called QueryResultsOrder to hold the field for sorting and the direction in one object.
Now you have all the data to call your service and put back the following to items in the request.
The last part I promised is the formatting of the cell. There is a BaseCell class that you can extend. The only method you need to overwiter is the html() method. There are a lot of utility methods. This method could look like this.
The HtmlBuilder object is used to append all html elements to. Line 4 obtains the style sheet class for the span element to create. Line 6 adds the span element and sets the style attribute class. The span element is also closed in line 6, this way the next text is added after the opening span element. This is done in line 7, and in line 8 the closing span element is added. Actually that is all there is to it. Sounds fun doesn't it?
Hope this helps some of you to get a quick start into the eXtremeComponents