Announcement Announcement Module
Collapse
No announcement yet.
Odd binding problem with dropdowns in jsp page Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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>

      Comment


      • #4
        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

        Comment


        • #5
          Hello Amit

          Next time use code tags.

          I suggest you read this 17. View technologies

          Comment

          Working...
          X