Use JSTL to control what content to be used in a table
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" val开发者_开发百科ue=" 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
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}">
精彩评论