Thursday, August 31, 2006

Using the Display Tag with external sorting and paging

I was comparing between using using Value List Handler and the Display Tag Library to do sorting and paging of my web appliaction's result sets and decided on using the Display Tag Library for it's much simpler configuration and because of the latest release's external sorting and paging features. Created a helper class to get the parameters provided by the display tag to pass to the DAOs, otherwise the code in the controller/action gets a litlle messy. Here's pieces of what i did.

In the JSP

In the controller (I'm using Spring MVC)

In the DAO

Currently the banner does not show correct values. e.g if u have 10 as the page size, it should show 1-10 for first page, 11-20 for second page. But it always shows 1-10 for all the pages. However, this will probably be fixed in next release.

Friday, August 18, 2006

Spring 2.0 form tags

I like the Spring's form tags. It just does what it what I wanted. Registered a custom date editor in the controller and used Spring's select tag for the date selection instead of input to a text box.

<form:select path="">
  <c:foreach var="date" begin="1" end="31" step="1">
    <form:option value="${date}"></form:option>

<form:select path="birthDate.month">
  <c:foreach var="month" begin="0" end="11" step="1">
    <form:option value="${month}" label="${1+ month}"></form:option>

<form:select path="birthDate.year">
  <c:foreach var="year" begin="45" end="106" step="1">
    <form:option value="${year}" label="${1900 + year}"></form:option>

  <spring:bind path="account.birthDate">
  <span class="error">${status.errorMessage}</span>
Doing forms for date inputs used to be a pain with Struts.

Hibernate Tools and Java Persistence API?

I missed using Hibernate's table generation tools. Currently am working on a web application and wanted to try learning to use the Java Persistence API . I am using netbeans 5.5 beta as my IDE and as of now, the table generation from entity classes can only be used when using the Sun Application server and using JSF as the web framework. As a temporary solution, I used the JSF/JPA/DDL generation and switched to running Spring MVC+JPA on the same project.