2011-04-20 62 views
1

我在表單上有一個輸入文本和一個按鈕。
我處理事件onchange的輸入文字和onclick的按鈕。
如果用戶更改文本,然後單擊按鈕2事件觸發,有時他們同時處理。
我想在onchange完成後處理onclick
爲此,我使用<a4j:queue name="myQueue"/>和標記事件與<a4j:queue name="myQueue"/>這樣的:使用a4j:隊列進行事件同步

<a4j:queue name="myQueue"/> 
    ... 
<h:inputText id="dateFromText" value="#{flowScope.fileSearchCriteria.fromDateStr}"> 
      <a4j:support event="onchange" eventsQueue="myQueue" reRender="datePanel1" 
      actionListener="#{fileSearchCriteria.changeTextFromDate}"/> 
</h:inputText> 
    .... 
<h:commandButton id="fileInSearch" action="fileInSearch" 
     value="#{resourceBundle.searchIn}" type="submit"> 
     <a4j:support eventsQueue="myQueue" event="onclick"/> 
</h:commandButton> 
... 

這樣做的結果,是onclickonchange每次處理不行。

回答

1

您應該每次都有兩個事件,onchange和onclick。但是,我建議切換到a4j:commadnButton,而不是在內部使用帶有a4j:支持的h:commandButton。

+0

我試過a4j:commandButton - 沒有效果。在「每次兩個事件」下你是什麼意思? – sergionni 2011-04-21 10:33:33

+0

按照激活組件的順序,您將有兩個事件。這裏有一篇關於隊列的好文章,可能有所幫助:http://www.jsfcentral.com/articles/richfaces_queue.html – 2011-04-22 17:25:37