• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to use the select tag - Struts2

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I press the button witch takes me to index.jsp where is this form(see below), the list cities from my Action is populated using a DB query.
Something like this (this is just a GENERAL photo, it's not from my code):




The question: how can I know what values are selected from the select tag in the Action? What is the name of variable which holds the chosen id?

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Create action properties named as the select elements are?

You should check out some of the Struts 2 tutorials before going too much further; dealing with forms in Struts 2 is pretty important stuff and should be understood.
 
Peter Mest
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is that I use the SAME action, for the both things.

When I press the button witch takes me to index.jsp, my "cities" properties is initialized using a static method;

List<City> cities = refresh();

And when I press the submit button, I go in the same Action, this time using the execute method(), but here the cities proprieties has the same values returned by refresh(). Any ideas?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what you're saying; the "list" attribute defines where the list values come from--not the action property that holds the selected values.

See how your textfield tag has a "name" attribute? Why doesn't your select tag?
 
Peter Mest
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:I'm not sure what you're saying; the "list" attribute defines where the list values come from--not the action property that holds the selected values.

See how your textfield tag has a "name" attribute? Why doesn't your select tag?




Moron.
I thought you use the select tag in a different way. I just found an example and copy-pasted in my code, without reading the documentation.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic