2012-09-27 68 views
0

我在modalPanel裏面有了這個inputTextarea,並且我得到更新後臺bean中相應值(motivePopupMotive)的唯一方法是在inputTextarea中添加一個a4j:support來設置ajaxSingle = TRUE,像這樣:在modalPanel裏面的inputTextarea不會更新後臺bean

<a4j:support event="onchange" ajaxSingle="true"></a4j:support> 

通過點擊按鈕 「btnSavePopupMotive」 調用保存方法之前。如果我不這樣做,那麼當我單擊「btnSavePopupMotive」按鈕時,後臺bean中的值總是空字符串。

但我不想要這個解決方案,因爲當我調用ajax函數時,我會顯示一個「加載」圖像,而且我不希望僅僅因爲用戶在此輸入中輸入一些文本而顯示此圖像。我怎麼能解決這個問題?這裏是代碼:

<div style="position: absolute;"> 
    <a4j:form id="form2"> 
     <r:modalPanel id="panelPopupMotive" resizeable="false" autosized="true" minWidth="300" minHeight="20" > 

      <table width="99%" bgcolor="#FFFFFF" style="border-collapse: collapse; border: 0px solid #000000;"> 
       <tr><td> 
         <fieldset> 
          <legend class="fmeSmallLegend"><h:outputText value="Motive" /> </legend> 
          <table><tr><td> 
           <h:inputTextarea id="motivePopupMotive" 
            onkeydown="verifySize(this, 200);" 
            onkeyup="verifySize(this, 200);" 
            onchange="verifySize(this, 200);" 
            value="#{ParameterFaces.motivePopupMotive}" 
            rows="4" style="width: 380px;" onfocus="this.style.background='#FFFED2';" onblur="this.style.background='#F5F5F5';"> 
           </h:inputTextarea>           
          </td></tr></table> 
         </fieldset> 
       </td></tr> 
       <tr> 
        <td align="center"> 
         <a4j:commandButton id="btnSavePopupMotive" 
          value="Save" onclick="saveMotive();" 
          style="width:80px" type="submit" 
          oncomplete="closePopupMotive();" 
          title="Save" reRender="motivePopupMotive,existsErrorMotive"> 
         </a4j:commandButton> 
         <r:spacer width="5px" /> 
         <a4j:commandButton id="btnCancel" 
          value="Cancel" style="width:80px" 
          oncomplete="Richfaces.hideModalPanel('panelPopupMotive');" 
          title="Cancel"> 
         </a4j:commandButton> 
        </td> 
       </tr>    
      </table> 
      <script type="text/javascript"> 
       function closePopupMotive(){ 
        if (document.getElementById('form2:motivePopupMotive').value == 'false'){ 
         Richfaces.hideModalPanel('panelPopupMotive'); 
        } 
       } 
      </script> 

      <a4j:jsFunction name="saveMotive" reRender="motivePopupMotive" oncomplete="saveValidatedMotive();"/> 

      <a4j:jsFunction name="saveValidatedMotive" actionListener="#{ParameterFaces.save}" reRender=""/> 
     </r:modalPanel> 
    </a4j:form> 
</div> 

謝謝!!

回答

1

原來是因爲我在窗體內部使用了modalPanel ......我把窗體放在了modalPanel之外,一切正常。