• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Select form error

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Can someone take a look what i'm doijg wrong about a jsp page?

This is my jsp (part)



Now i want to use the value of ${emp[4]} in a select form


But my select show me all


How can i reach what i pretend?'

Thanks

 
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question is not clear.

Is the form part of JSP above?
Where is your select showing all options?
 
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Thank you for your help

This is my jsp form



I receive a sql query in the forEach, then i want to use a value to use in the form to fill in <form select

Thanks
 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So in your form, you want to display only 4th element of the list as a select option?

Then, just use ${empList[4]} as the option. No need for <c:forEach>.
Or if you want to display a property value of employee, use ${empList[4].name}
 
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

i put the code like this



And the select box is wrongly populated

Check the image, the select list retrives all the index [0,1,2,3,4] instead of only 4

What's wrong??
selct.jpg
[Thumbnail for selct.jpg]
select
 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this way.
 
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Surendra

Thanks again

Npw it is worst, nothing is retrivied

Check the image and my full code



empty.jpg
[Thumbnail for empty.jpg]
empty
 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what objects are in empList? and what properties?
What property of elements are you trying to display in select?
 
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

what objects are in empList? it is query list
and what properties? (code, name, email, telefone and type of employee)
What property of elements are you trying to display in select? I want to use the properties of Tipo (type of employee)
As you can see by the image, the list works, i just want to use values of Tipo (last index) into a select form

Follow the arrows

Check the image

selct1.jpg
[Thumbnail for selct1.jpg]
list
 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then this should work.
Please adjust names as per your real values.

If you still can't see anything, please print the ${empList[4]} using <c:out> tag before the form.
See also the source.

 
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Thanks again but doesn't work

The only thing it works partially is this



But i have the last record ("Mecanico") in the list, i need more (Gestor, Operador, Motorista), retrieves the last record
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like the form is to add a new emp. If this is the case you should not be using the type off of the employees in the list in the select. There could be duplicate or missing types. It looks like types is a predetermined set of objects. I would populate that in your controller. Maybe something like below (not tested)



Once types is on the model simply use them in your form

 
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I just resolved like this

 
It's a tiny ad. At least, that's what she said.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic