2
再次,PrimeFaces和GAE的組合讓我瘋狂。在p:dataTable
的內部,我想單擊一個圖像,調用一個bean方法並設置一個參數。該方法被調用,但該參數不起作用。下面是一個簡單的例子(不帶表):Google App Engine:f:setPropertyActionListener with p:ajax
<h:form id="f1">
<h:outputText id="text" value="#{testBean.index}"/>
<h:graphicImage url="/images/cut.png">
<p:ajax event="click" process="@this" update="text"
actionListener="#{testBean.test}" >
<f:setPropertyActionListener target="#{testBean.index}" value="5" />
</p:ajax>
</h:graphicImage>
</h:form>
我TestBean
看起來是這樣的:
@javax.faces.bean.ManagedBean @ViewScoped
public class TestBean implements Serializable{
private int index; // getter/setter
@PostConstruct public void init() {
index = 0;log.log(Level.WARNING, "@PostConstruct");}
public void test(ActionEvent ae){
log.log(Level.WARNING, "Index: "+index);}
}
在我看到一個@PostConstruct
的日誌和點擊圖像總是Index: 0
後更新值更新問題可能在這裏討論JSF GAE: Value Update Problem in managed bean method
說明:''僅在實現'ActionSource'的父組件支持。 ''沒有。然而,有趣的細節是,當你使用''而不是''時,拋出了一個異常,正是這個消息。 ''順便也可以用所需的'替換。 ''順便說一句,在'
'內部不會有''的效果。 –
BalusC
@BalusC,我沒有意識到這一點,並且學到了一些新東西,但是如果仔細觀察,會發現''實際上位於''標籤內部,縮進是棘手的。雖然這是很好的信息。 –
''不能是另一個''的孩子。它將僅僅是父級「UIComponent」的子級。 –
BalusC