2012-02-08 64 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> 
相關問題