Results 1 to 5 of 5

Thread: Odd binding problem with dropdowns in jsp page

  1. #1
    Join Date
    Feb 2011
    Posts
    19

    Default Odd binding problem with dropdowns in jsp page

    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.


    Code:
    <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

  2. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,806

    Default

    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
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  3. #3
    Join Date
    Feb 2011
    Posts
    19

    Default

    Thanks for the reply dr_pompeii,

    I fixed the issue by

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

    Regards,
    Kevin

    Code:
    <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>

  4. #4
    Join Date
    Apr 2012
    Posts
    3

    Default

    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

  5. #5
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,806

    Default

    Hello Amit

    Next time use code tags.

    I suggest you read this 17. View technologies
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •