我需要一些幫助來獲取我的複合組件的行爲。我仍然在學JSF中的繩索,所以請原諒可能在這篇文章中顯示的任何無知。JSF2.0複合組件actionListener
因此,我正在使用JSF 2.0,並決定構建一個複合組件來使這個特定的代碼片段可重用。該組件完美地顯示了一切,但在嘗試添加actionListener時完全不會表現出來。
這裏是我的組件的代碼
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface displayName="columnUpdate">
<composite:attribute name="id"
required="true"
displayName="id"
shortDescription="Id to apply to this control and its child components">
</composite:attribute>
<composite:attribute
name="value"
displayName="value"
required="true"
shortDescription="Field that will hold the new updated value.">
</composite:attribute>
<composite:attribute
name="columnName"
displayName="columnName"
required="true"
shortDescription="Value that will be applied as the column header">
</composite:attribute>
<composite:attribute
name="text"
displayName="text"
shortDescription="Text to be displayed above the field">
</composite:attribute>
<composite:actionSource name="actionEvent" targets="saveEvent"></composite:actionSource>
</composite:interface>
<composite:implementation>
<h:outputLabel value="#{cc.attrs.columnName}" onclick="showWindow('#{cc.attrs.id}')"></h:outputLabel>
<div id="#{cc.attrs.id}" class="ccColumnUpdate">
<div id="windowClose" onclick="closeWindow('#{cc.attrs.id}');" style="top: -10px;" title="Close this window">CLOSE</div>
<div>
<h:outputLabel id="lblTitle" value="#{cc.attrs.text}"></h:outputLabel>
</div>
<div>
<h:inputText id="txtValue" value="#{cc.attrs.value}"></h:inputText>
</div>
<div style="text-align:right;">
<h:commandButton id="saveEvent" value="Save"></h:commandButton>
</div>
</div>
</composite:implementation>
</ui:composition>
這裏是我的網頁使用該組件的代碼:
<al:columnUpdate id="cuExpenseAmount" value="#{expense.columnValue}" columnName="Expense Amount" text="Set Expense Amount to:">
<f:actionListener for="actionEvent" binding="#{expense.updateColumnValue}">
<f:ajax execute="@form"></f:ajax>
</f:actionListener>
</al:columnUpdate>
,這裏是我的支持bean代碼:
public void updateColumnValue(ActionEvent event) throws ParseException{
//Got HERE
}
我沒有收到任何錯誤或打到我在輔助bean上設置的任何斷點。任何幫助,或正確的方向指針將不勝感激。
問候,
邁克