【问题标题】:JSP form selection tag, display inner listJSP表单选择标签,显示内部列表
【发布时间】:2012-02-08 11:01:24
【问题描述】:

我的班级如下

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 并显示相应的下拉菜单,我该怎么做?

【问题讨论】:

    标签: forms jsp taglib


    【解决方案1】:

    经过深思熟虑,我有一个解决方案,但从长远来看,它会导致性能问题,在我有更多 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>
    

    【讨论】:

      猜你喜欢
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      • 2017-10-31
      • 2021-01-14
      • 2014-05-31
      • 2010-11-19
      • 1970-01-01
      • 2021-05-03
      相关资源
      最近更新 更多