2012-02-08 61 views
0

我的班级如下JSP形式选择标记,显示内部列表

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> 

done如果我CriteriaConfig的定义为

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

现在我想检查displayName被选中并显示相应的下拉菜单,我该怎么做呢?

回答

0

经过多少思考,我有一个解决方案,但从长远来看,当我有更多数量的CriteriaConfig对象时,它会导致性能问题,但尽管如此,除非有人提出了这个问题一个更好的soln。

<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> 
相关问题