Results 1 to 6 of 6

Thread: how to fine SelectedValue in Spring jstl select tag

  1. #1

    Default 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

  2. #2
    Join Date
    May 2006
    Location
    Rotterdam
    Posts
    58

    Default

    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

  3. #3

    Default

    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

  4. #4

    Default

    Thanks for you help. I have fixed the issue.

    Satya

  5. #5
    Join Date
    May 2006
    Location
    Rotterdam
    Posts
    58

    Default

    what was the solution?

  6. #6

    Default

    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
  •