Announcement Announcement Module
Collapse
No announcement yet.
Drop down lists Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Drop down lists

    Hi,
    I have 2 pages.
    One of them is a list and the other is a form.
    From the list page if I click any of the listed items, the form page is opened for modifying the data.
    The form has a number of edit boxes and a drop down list.
    What I want is that when I open the form for modification the value that appears in the drop down list is the value of the item I want to modify (the one clicked in the list page).
    How could this be done?
    Thanks in advance.
    Sherihan.

  • #2
    You can do something like this:
    Code:
            <spring&#58;bind path="customer.title">
              <td width="20%">
                  <select name="title">
                      <c&#58;forEach items="$&#123;title&#125;" var="opt" >
                          <option value="<c&#58;out value="$&#123;opt&#125;"/>"
                              <c&#58;if test="$&#123;opt == status.value&#125;">selected</c&#58;if>/>
                              <c&#58;out value="$&#123;opt&#125;"/></option>
                      </c&#58;forEach>
                  </select>
              </td>
              <td width="60%"><font color="red"><c&#58;out value="$&#123;status.errorMessage&#125;"/></font></td>
            </spring&#58;bind>
    title is a collection in the model with the values for the drop down list.
    The current value in the command object (command.title) will be selected.

    Just make sure your command object is populated correctly, e.g. in formBackingObject()

    HTH

    Comment


    • #3
      Hi,
      Thanks.
      But this doesn't solve my problem.
      What I want is that if the item i select in the first page has a value x for a property name for example.
      Then this x appears selected in the form in the drop down list.
      My code is exactly like the example you sent but it doesn't function.
      Thanks.
      sherihan.

      Comment


      • #4
        Originally posted by sherihan
        Hi,
        What I want is that if the item i select in the first page has a value x for a property name for example.
        Then this x appears selected in the form in the drop down list.
        before going to the new form are you setting it's name property to x; like for example:

        myFormBackingObject.setName("x");

        ATTA

        Comment


        • #5
          Hi again ,
          Where should I add this line?
          I call the form from a link (href) in another page (ListController).
          So I want the the value of a certain property of the selected link to appear in the drop down menu in the Form page.
          thanks.
          Sherihan

          Comment

          Working...
          X