aspose file tools*
The moose likes Spring and the fly likes Select form error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Select form error" Watch "Select form error" New topic
Author

Select form error

Gil Carvalho
Ranch Hand

Joined: Dec 10, 2013
Posts: 56
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

Surendra Kumar
Ranch Hand

Joined: Jul 04, 2006
Posts: 235
Question is not clear.

Is the form part of JSP above?
Where is your select showing all options?
Gil Carvalho
Ranch Hand

Joined: Dec 10, 2013
Posts: 56
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

Joined: Jul 04, 2006
Posts: 235
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

Joined: Dec 10, 2013
Posts: 56
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]

Surendra Kumar
Ranch Hand

Joined: Jul 04, 2006
Posts: 235
Try this way.
Gil Carvalho
Ranch Hand

Joined: Dec 10, 2013
Posts: 56
Hi Surendra

Thanks again

Npw it is worst, nothing is retrivied

Check the image and my full code






[empty.jpg]

Surendra Kumar
Ranch Hand

Joined: Jul 04, 2006
Posts: 235
what objects are in empList? and what properties?
What property of elements are you trying to display in select?
Gil Carvalho
Ranch Hand

Joined: Dec 10, 2013
Posts: 56
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]

Surendra Kumar
Ranch Hand

Joined: Jul 04, 2006
Posts: 235
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 <cut> tag before the form.
See also the source.

Gil Carvalho
Ranch Hand

Joined: Dec 10, 2013
Posts: 56
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
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1680
    
    7

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



[How To Ask Questions][Read before you PM me]
Gil Carvalho
Ranch Hand

Joined: Dec 10, 2013
Posts: 56
Hi

I just resolved like this

 
 
subject: Select form error