我需要實現一個將列表傳遞給其後備bean的ice:commandButton
。我不在portlet範圍內,但在標記範圍內。f:屬性是否支持String以外的其他東西?
我知道當我從actionListener檢索到f:attribute
時,我得到一個必須被轉換的對象。
我想知道如果我可以映射f:屬性爲List<MyClass>
,在列表中的實際情況是實際上的ArrayList
和MyClass
是序列化的。
喜歡的東西:
MyTag.xhtml
<ice:commandButton actionListener="#{TagBean.doPrintItems}">
<f:attribute name="collection" value="#{items}" />
</ice:commandButton>
//[other things]
MyPortlet.jspx
<my:printPopup items="#{BackingBean.itemsToPrint}" />
BackingBean.java
class BackingBean {
private List<MyClass> itemsToPrint;
//getter and setter of course
}
TagBean.java
class TagBean {
private List<MyClass> collection;
//getter and setter of course
public void doPrint(ActionEvent e) {
collection = (List<MyClass>) e.getComponent().getAttributes().get("collection");
}
您認爲這樣可行嗎?謝謝
它應該只是工作。你面臨的問題是什麼?這個問題並不清楚。 – BalusC
沒問題。在進行此操作之前,我還有其他任務需要執行。 **如果我用按鈕觸擊了**,發現這種方式不可行,那麼我肯定會大幅回滾。我期望在下週一進入按鈕的事情 –