JSP表单选择标记,显示内部列表

时间:2012-02-08 11:01:24

标签: forms jsp taglib

我的课程如下

public class CriteriaConfigImpl implements CriteriaConfig {

    private long elementId;
    private String displayName;
    private String dataType;
    private String internalMap;
    private int displayOrder;
    private List<OperandType> operands;

    //..Setter Getter..//
}

我的主要课程是

public class Query {
    private Long id;

    @NotNull
    @Size(min = 0, max = 1500)
    private String queryString;

    private String searchFilterCondition;

    private List<CriteriaConfig> configuredCriteriaList;

    //.. Other operations ..//

}

在我的JSP页面上,我想将操作数显示为列表,目前我已将其作为

<form:select path="searchFilterCondition" multiple="false">
                        <form:options items="${query.configuredCriteriaList}" itemLabel="operands" value="operands"/>
                    </form:select>

如果我的CriteriaConfig被定义为

1. CriteriaConfig {1, "Test1", "String", "Test1", 1, "AND, OR, NOT" }
2. CriteriaConfig {2, "Trial", "Date", "Trial", 2, "LESSTHAN, GREATERTHAN" }

现在我想查看选择了什么displayName并显示相应的下拉列表,我该怎么做?

1 个答案:

答案 0 :(得分:0)

经过深思熟虑我有一个解决方案,但是从长远来看会导致性能问题,在我有更多CriteriaConfig对象的情况下,但是,这就是我现在所拥有的,除非有人想出一个更好的解决方案。

<c:forEach items="${query.configuredCriteriaList}" var="queryOperations" varStatus="loopStatus">
                        <c:out value="${loopStatus.count}"/>
                        <c:out value="${queryOperations.displayName}"/>
                        <!-- If we want to display the operands specific for a display type, then we need the condition else, we can ignore it -->
                        <c:if test="${queryOperations.displayName=='Test1'}">
                            <form:select path="searchFilterCondition" multiple="false">
                                <form:options items="${queryOperations.operands}"  value="${queryOperations.operands}" itemLabel="operandType"/>
                            </form:select>
                        </c:if>
                    </c:forEach>