PDA

View Full Version : Odd binding problem with dropdowns in jsp page



kkelleher
Apr 12th, 2012, 03:40 AM
Hi,

I am using spring web flow 2.0 & hibernate.

I wish to have 3 dropdowns, - country of birth, nationality & address, obviously each presenting a list of countries, on a jsp page.

When the page just has one of the dropdowns (any one) , all works ok, for the relevant field, the country selected is saved.

However with all 3 on the page

selecting a country in the first drop down leads to that value being saved for all 3 fields.
selecting a country in the second or third dropdown does not lead to that value being saved.



<form:select path="countryBirth.codeID" style="width:170px" id="_countryBirth">
<form:options items="${countryList}" itemValue="codeID" itemLabel="codeDescription"/>
</form:select>

<form:select path="country.codeID" style="width:200px" id="_country">
<form:options items="${countryList}" itemValue="codeID" itemLabel="codeDescription"/>
</form:select>

<form:select path="nationality.codeID" style="width:200px" id="_nationality">
<form:options items="${countryList}" itemValue="codeID" itemLabel="codeDescription"/>
</form:select>

Any ideas?
Thanks in advance,
Kevin

dr_pompeii
Apr 15th, 2012, 02:43 PM
Hello

1)Could you post the POJO that is represented in such form?
2)Post your controller's code to see how you are filling the data in the model and how you handle the submit event

kkelleher
Apr 17th, 2012, 08:59 AM
Thanks for the reply dr_pompeii,

I fixed the issue by

a) Making the code change below
b) Adding a converter

Regards,
Kevin


<form:select path="countryBirth" style="width:170px" id="_countryBirth">
<form:options items="${countryList}" itemValue="codeID" itemLabel="codeDescription"/>
</form:select>

<form:select path="country" style="width:200px" id="_country">
<form:options items="${countryList}" itemValue="codeID" itemLabel="codeDescription"/>
</form:select>

<form:select path="nationality" style="width:200px" id="_nationality">
<form:options items="${countryList}" itemValue="codeID" itemLabel="codeDescription"/>
</form:select>

amitimsmca
Apr 30th, 2012, 07:51 AM
Hi,

How to show the default value seleted in drop down options.
if i am setting two attribuite in the model in controller
--controller---

model.put("mydesignation","manager");
model.put("designationlist","designationlist");

---jsp---
now on jsp i want "manager" to be selected by default in designation drop down list.

<form:select path="designation">
if(${mydesignation == designationlist.item}) -- then selected
<form:options items="${designationlist}" />
</form:select>

I am not able to do this.
Kindly help me to solve this problem.

Thanks,
Amit

dr_pompeii
Apr 30th, 2012, 11:24 AM
Hello Amit

Next time use code tags.

I suggest you read this 17. View technologies (http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/view.html)