3
我正在製作複合組件,其中我有commandButton。但它不起作用。行動和actionListener爲複合組件中的p:commandButton
用法:
<wk:commandButton value="Non-Ajax actionListener" actionListener="#{ioBean.saveListener}" />
組件的代碼:commandButton.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:cc="http://java.sun.com/jsf/composite">
<cc:interface>
<cc:attribute name="value" />
<cc:attribute name="action" method-signature="void action(javax.faces.event.ActionEvent)" default="null"/>
<cc:attribute name="actionListener" method-signature="void actionListener(javax.faces.event.ActionEvent)" default="null"/>
<cc:attribute name="styleClass" default="button" />
</cc:interface>
<cc:implementation>
<p:commandButton
value="#{cc.attrs.value}"
action="#{cc.attrs.action}"
actionListener="#{cc.attrs.actionListener}"
styleClass="#{styleClass}">
<cc:insertChildren />
</p:commandButton>
</cc:implementation>
</html>
這是日誌:
0000006c FaceletViewDe E Inner component action not found when retargetMethodExpressions
0000006c FaceletViewDe E Inner component actionListener not found when retargetMethodExpressions
0000006c srt W com.ibm.ws.webcontainer.srt.SRTServletResponse setIntHeader SRVE8094W: Ostrzeżenie: nie można ustawić nagłówka. Odpowiedź została już zatwierdzona.
我認爲這個問題是行動和默認值ActionListener的。但根據PrimeFaces文檔,action和actionListener的默認值爲null。 一種選擇是製作四種不同的變體,其中action和actionListener爲null或被定義,但它似乎不是一個好的解決方案。
是你的wk:commandButton在表單標籤內嗎?將下面的代碼添加到p:commandButton:ajax =「#{empty cc.attrs.actionListener?false:true}」 – Yamada
我不想在這種情況下使用ajax。就像按鈕中的值所說的那樣。 :) – WojciechKo
所以把阿賈克斯=「假」。默認值是true。 – Yamada