tags:

views:

108

answers:

1

Hi all, I would like to use a different ArrayList for the content of a table based on a user selected value.

I am using the display:table tag for the display

<display:table name="${aVariableName}">
    <display:column property="trackNumOfType" title="Track (# of Types)" sortable="true"></display:column>
    <display:column property="typeNumOfFeature" title="Type (# of Features)" sortable="true"></display:column>
</display:table>

How can I replace the aVariableName based on user's selected value in a dropdown list that should be the name of another set variable?

For your reference, this is my dropdown list:

<form method="post" action="PostBackToTheCurrentJSP.jsp">
    <select name="choice" size="1" onchange="submit()">
        <c:forEach var="chrms" items="${LocationName}" varStatus="loopStatus">
            <c:choose>
                <c:when test="${param.choice == chrms.name}">
                    <c:set var="selectedInd" value=" selected"></c:set>
                </c:when>
                <c:otherwise>
                    <c:set var="selectedInd" value=""></c:set>
                </c:otherwise>
            </c:choose>
            <option value="<c:out value='${chrms.name}' />" <c:out value='${selectedInd}' />>
                <c:out value="${chrms.name}"></c:out>
            </option>
        </c:forEach>
    </select>
</form> 

If using JSTL is not feasible since there is no nested EL, do you have any other way to do it? Thanks in advance.

Kenneth

A: 

In other words, you want to use the submitted selected value of the HTML <select> element in the name attribute of the displaytag? I.e. you want to use request.getParameter("name") there? You can access request parameters in EL by ${param} as follows: ${param.name}.

Since the dropdown has a name of choice, the following should work:

<display:table name="${param.choice}">
BalusC
Hi BalusC, thanks for your response. I had tried it but doesn't work, for example, user selected 'Ch1' in the dropdown list. Then ${param.choice} will equal to 'Ch1'. But in my case, 'Ch1' is the name of an ArrayList. So for the display tag, I would need name="${Ch1}". Since it does not allow nested EL, name="${${param.choice}}" won't work.After some thoughts, I had a work around. I put all the 'Ch*' ArrayList into an ArrayList, then in the display tag, I use name="${AllCh[curChIndex]}". AllCh has the type of ArrayList<ArrayList<TableRecord>>. Thanks for your effort in helping.Kenneth
Kenneth
Use `${requestScope[param.choice]}` then as hinted in your previous question. Or if it's in the session scope, `${sessionScope[param.choice]}`.
BalusC