2012-01-04 52 views
0

我的表單包含以下元素:綱領性部分提交

  1. ICEfaces的文本字段輸入搜索條件。
  2. icefaces命令按鈕(查找)使部分提交並填充與新的匹配用戶列表的div。
  3. 其他兩個icefaces文本字段,當提交整個表單時,我需要它們的值。

要求:我想,當用戶按在文本輸入字段中輸入,即找到按鈕被點擊(當按鈕被用鼠標點擊它使部分自動提交)

所以這裏是我的嘗試:

<ice:inputText id="recipient" value="#{myBean.searchValue}" size="60" 
        onkeydown="handleEnter(event,this.form);" > 
       </ice:inputText> 

       <ice:commandButton id="find" value="Find" action="#{myBean.findEmployees}" partialSubmit="true" 
        > 
        <f:ajax execute="@this" render="employees" /> 
       </ice:commandButton> 
  • 的JS方法:

    function handleEnter(event,form){ 
    
        if (event.keyCode == 13){ 
        document.getElementById(form.name+':find').click(); 
        } 
    } 
    
  • 生成的冰命令按鈕:

    <input type="submit" value="Find" style="width: 60px;"  onfocus="setFocus(this.id);"  onclick="iceSubmitPartial(form, this, event);return false;" onblur="setFocus('');" name="myForm:find" id="myForm:find" class="iceCmdBtn findButton"> 
    

問題:會發生什麼情況是,當用戶按回車,發現按鈕被調用,但整體形式被提交,所以出現需要驗證錯誤爲另外兩個文本字段。

請告知爲什麼整個表單正在提交,以及如何處理此類問題。

+0

真的,我不知道究竟HTML的'<冰:commandButton>效果'產生,但嘗試'的onclick的()''而不是點擊()'。它只會觸發按鈕的「onclick」功能,而不是點擊按鈕。 – BalusC 2012-01-04 17:50:04

+0

@BalusC,onclick給出了相同的行爲,我添加了冰命令按鈕的生成代碼。 – 2012-01-05 12:31:43

回答

0

爲了讓輸入按鈕在部分提交時正常工作,我必須從輸入中刪除'required = true'標籤並使用JS進行驗證。

-1

設置immediate =按鈕

+3

請解釋你的答案。 – Prudhvi 2015-07-24 14:24:29