-
Apr 15th, 2008, 10:17 PM
#1
how to fine SelectedValue in Spring jstl select tag
Hi,
I am new to jstl core and Spring and have been searching for the solution for the below scenario for 2 days and finally registered to this site today.
I am trying to find the selectedValue of a select tag:-
eg:-
<select name="domains">
<c:forEach var="res" items="${model.domainList}">
<c:option value="<c:outvalue='${res.id}'/>"><c:outvalue="${res.name}"/></c:option>
</c:forEach>
</select>
here i want to find the selected value, so that based on the selected value from the above list ,
i should grab the domain object form the domainList and display the domain properties in a html table.
Can any one please help me here, it is a bit urgent.
Thank you ,
Satya
-
Apr 16th, 2008, 03:07 AM
#2
If I understand your question correctly, you want to know how to bind the user's selection to your Form Backing Object so you can retrieve and display the list item.
See http://static.springframework.org/sp...rence/mvc.html
search the page for "The options tag" and pay attention to the path= attribute
-
Apr 16th, 2008, 10:45 AM
#3
Thanks for the quick response. Let me explain you clearly what am doing and any pseudo code would be of much help here.
MyController extends MultiActionController
List<Domain> allDomainList = service.getDomains();
Map myModel = new HashMap();
myModel.put("domainsList",allDomainList);
return new ModelAndView( "configuration/domain", "model", myModel );
MyJsp:-
<select name="domains">
<c:forEach items="${model.domainsList}" var="res" >
<option value=<c:out value="${res.domainId}"/>>
<c:out value="${res.name}"/></option>
</c:forEach>
</select
Now I want to take the selectedDomain and then display a table something like this..
<c:forEach items="${model.domainsList}" var="res" >
<c:if test="${ res.domainId== param.domains}">> ******** here param.domains is not working..................... (what iam expecting with param.domains is selectedDomain value from the select)
<table>...
<td> c:out value="${res.domainType}"/></</td>
<td>c:out value="${res.domainName}"/></</td>
...............
</c:if>
</c:forEach>
Please let me know, if am still not clear.
Thanks a lot,
Satya
-
Apr 16th, 2008, 01:27 PM
#4
Thanks for you help. I have fixed the issue.
Satya
-
Apr 16th, 2008, 01:55 PM
#5
-
Apr 16th, 2008, 09:18 PM
#6
Actually I was somehow trying to capture in the same jsp without form submission, but realised no way of doing
atleast could not identify a way , so doing a form submission and getting the selected domain.
Please let me know,if you have a better solution.
Thanks
Satya.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules