PDA

View Full Version : Drop down lists


sherihan
Jan 25th, 2005, 05:38 AM
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.

cmgharris
Jan 25th, 2005, 07:05 AM
You can do something like this: <spring:bind path="customer.title">
<td width="20%">
<select name="title">
<c:forEach items="${title}" var="opt" >
<option value="<c:out value="${opt}"/>"
<c:if test="${opt == status.value}">selected</c:if>/>
<c:out value="${opt}"/></option>
</c:forEach>
</select>
</td>
<td width="60%"><font color="red"><c:out value="${status.errorMessage}"/></font></td>
</spring: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

sherihan
Jan 25th, 2005, 08:33 AM
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.

ATTA
Jan 25th, 2005, 09:30 AM
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

sherihan
Jan 25th, 2005, 10:40 AM
Hi again :D ,
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