我在RichFaces 4.5.2.Final和JSF 2.1上,想要使用选项列表组件。我目前写下以下标记:
<rich:pickList id="lotoGames2" var="game"
value="#{jackpot.selectedGameList}"
converter="gameConverter"
listsHeight="100px" sourceListWidth="100px" targetListWidth="100px">
<f:selectItems value="#{jackpotBean.availableLotoGames}" var="game" itemValue="#{game}" itemLabel="#{game.name}" />
<f:facet name="sourceCaption">
<h:outputText value="#{msgs['drawForm.availableGames']}" />
</f:facet>
<f:facet name="targetCaption">
<h:outputText value="#{msgs['drawForm.selectedGames']}" />
</f:facet>
<rich:column>
<h:outputText value="#{game.name}" />
</rich:column>
</rich:pickList>
左手边正在填充,但右手边没有。我不知道它有什么问题。我为jackpot.selectedGameList
的setter设置了一个断点,并确保它返回实际值,但是它返回的List
没有在右侧呈现。这可能是什么问题?
UPD:收到BalusC的评论似乎很重要的是,"#{jackpot.selectedGameList}"
被称为List<GameDTO>
,其中GameDTO
会覆盖hashCode
和equals
方法。
以下是GameDTO
的样子:
public class GameDTO {
private int id;
private String code;
private String name;
//Constructor, GET, SET
@Override
public int hashCode() {
return id;
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object == null || getClass() != object.getClass()) {
return false;
}
GameDTO other = (GameDTO) object;
return id > 0 && other.id > 0 && id == other.id;
}
}