This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic