Win a copy of Svelte and Sapper in Action this week in the JavaScript 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to poplulate a Spring form dropdown via SQL table

 
Ranch Hand
Posts: 1087
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I wanted to know, how to poplulate a Spring form dropdown via SQL Table.

I tried googling it, but it was of no help.
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would call one of your methods in your @Respostiory. The method would return a collection of options to populate your drop down box with. It might look something like this if your drop down were categories.



The database look-up work would be done in myRepository.

Once you have the list your question merely becomes how to populate a selection box.

If you are just selecting a list of Strings it is very simple. If you are using objects there is a little more to it. See this thread from a couple days ago. Pieces of it may be relevant to you.

https://coderanch.com/t/591440/Spring/ID-isn-binded-form-object

Also have a look at the reference documentation:
http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/view.html#view-jsp-formtaglib-selecttag
 
Vishal Hegde
Ranch Hand
Posts: 1087
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Bill,

I want it in JSTL tag format Like the below lines


 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you are doing what the options tag does for you. If you want to do it that way you can but it should be within a select. You also need to use the Spring taglib for your select and option elements if you want it bound to your object.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic