Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Spring pre-select/pre-populate MULTI-SELECT box OPTIONs

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Book class which has properties such as id (long), name (String). Also, one of its properties is



Author has properties such as id, name, biography.

I have a book search form in which the total set of the Authors in my DB appears in a multi-select box. I was able have the authors that were selected by the user sent correctly to the controller (i.e. I could get them through the command as Set of Authors), but I want the next page (i.e. the result view page, which is the same page as the first search page) also to show the original search form filled with the values that were selected by the user. This was easy with regular text fields, e.g. the book's name: in the controller I got them loaded on the command object, and I simply kept them unchanged before sending the same command object to the view. But keeping the command's Set of Authors did not cause the view page to pre-select the relevant Authors in the multi-select box.... HOW DO I DO THIS TRICK???

I have read in the following stackOverFlow link

Spring MVC JSTL preselected list

that I need to "to override the equals method of the" Author class.... I did it (two Author classes are equal if they have the same id), but it did not help. Still, no Author is selected in the multi-select box in result page after I submit the search form.

Thanks!
 
Squanch that. And squanch this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic