Spring Framework
Multiple Selection Binding for Complex Objects in Spring
Submitted by Aaron Longwell on Thu, 2006-11-23 21:54.I ran into an issue where I needed to offer a multiple select interface to edit a many-to-many association of one domain object to another (assigning multiple roles to a user).
This JRoller Post helped me solve the issue.
Using Velocity Toolbox Features in Spring
Submitted by Aaron Longwell on Tue, 2005-12-27 17:07.Today the need to URL encode some URLs within a Velocity view came up in a Spring application of mine. After a few failed attempts to get a LinkTool working, I found the issue. There was a problem with the formatting of my toolbox.xml file. I thought I'd better recap the complete setup for using Velocity toolbox views in Spring.
First, I define a VelocityViewResolver in my servlet beans configuration file (spring-servlet.xml). I define a
Nested Data Binding Customization in Spring
Submitted by Aaron Longwell on Fri, 2005-07-01 13:45.As covered elsewhere, Spring's MVC databinding can be customized using the ServletRequestDataBinder's registerCustomEditor methods. In most cases, you specify just the data type or a combination of data type and field name (for field-specific data binding rules).
I ran into trouble trying to customize the data binding of a nested Collection component's field. It turns out it's just as easy, just not very intuitive.
To register a custom PropertyEditor for a nested field, you use the same method as a non-nested field, but you use a special syntax for the field name. The following is a hypothetical example binding an Order object. The Order contains a field called customer, which is of type Person. The Person class has its own field birthDate.
Custom Date Formatting with Spring Data Binding
Submitted by Aaron Longwell on Mon, 2005-06-13 16:38.
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception
{
super.initBinder(request, binder);
binder.registerCustomEditor(Date.class,
"estimatedCompletionDate",
new CustomDateEditor(new SimpleDateFormat( "M/d/yy"), true)
);
}
Data Binding to Multiple Records in Spring (with Velocity)
Submitted by Aaron Longwell on Mon, 2005-06-13 14:54.A client came to me recently asking for modifications to their web application. The application has a many to one relationship; we'll call it the "one" side a Studio, and the "many" side's elements "Films". Updated information for films (box office numbers, tickets sold, etc) comes in batches. Searching, selecting and editing Films one at a time is inefficient, so the client requested batch editing ability.
We started from the user's perspective and decided a spreadsheet-style interface would be most efficient. Users will perform a search to get a list of Films, then edit them in the spreadsheet interface. This required data binding to multiple database records simultaneously.
