簡體   English   中英

如何從ActionEvent對象獲取組件值?

[英]How to get component value from ActionEvent object?

我使用ajax4jsf與jsf 1.1,我有如下代碼:

<h:selectOneMenu id="INPUT_PO_DocCategory" binding="#{PrinceOfficeBean.PO_DocCategory}" style="width:200px;">
          <f:selectItem itemLabel="test" itemValue="123"/>
          <f:selectItem itemLabel="test2" itemValue="456"/>
         <a4j:support event="onchange" actionListener="#{PrinceOfficeBean.processDocumentCategoryValueChange}" reRender="INPUT_PO_DocType" />
</h:selectOneMenu> 

這段代碼是靜態的,我可以通過PO_DocCategory綁定對象得到selectOne值,問題是:是否可以通過action事件對象獲取actionlistener中的組件值?

public void processDocumentCategoryValueChange(ActionEvent e) throws Exception {
   // get component value from ActionEvent 
 }

JSF中的經典方法是使用輸入組件的value屬性,例如:

<h:selectOneMenu value="#{bean.value}">
    ...
</h:selectOneMenu>

輸入值將存儲在bean value屬性中,並可由操作偵聽器用於操作。

仍然可以以“替代”方式獲取動作偵聽器中的值:

((EditableValueHolder) event.getComponent().getParent()).getValue() 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM