Having successfully used SWF 1.x in many of our applications I am now trying to familiarize myself with the changes and new ideas of SWF 2.x. It all looks very promising, but I have encountered an unexpected binding problem related to the form:checkbox tag. I realize that there are many postings on the form:checkbox(es) tag, but none seem to address this particular issue.
The idea is to have a list of items on my form object that can be deleted using checkboxes. I have designed the form object along the lines of the example in section 14.2.4.4 in the reference documentation:
The problem is this. Everything works fine, i.e. binding occurs and elements are deleted as long as 2 or more checkboxes are checked. If only one checkbox is checked, thenCode:public class LibraryForm implements Serializable { List books = new ArrayList(); public LibraryForm() { for (int i = 0; i < 10; i++) { books.add(new Book(i, "Book number " + i)); } } public void setBookIdsToDelete(String[] bookIdsToDelete) { System.out.println("setBookIds called: " + bookIdsToDelete.length); List booksToDelete = new ArrayList(); for (int i = 0; i < bookIdsToDelete.length; i++) { Book bookToDelete = (Book) books.get(Integer.parseInt(bookIdsToDelete[i])); booksToDelete.add(bookToDelete); } books.removeAll(booksToDelete); } public String[] getBookIdsToDelete() { return null; } public List getBooks() { return books; } private class Book implements Serializable { private int id; private String title; public Book(int id, String title) { this.id = id; this.title = title; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } } }
is never invoked. The relevant part of my view page is thisCode:public void setBookIdsToDelete(String[] bookIdsToDelete)
I am using SFW 2.0.2 and Spring 2.5.4.Code:<form:checkboxes path="bookIdsToDelete" items="${booksList}" itemValue="id" itemLabel="title" delimiter="<br/>"/>
Is this a bug or am I missing something? Thanks in advance.


Reply With Quote
