0

我在 modalPanel 中有这个 inputTextarea,我在支持 bean 中更新相应值 (motivePopupMotive) 的唯一方法是在 inputTextarea 中添加 a4j:support 来设置 ajaxSingle=true,如下所示:

<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>  

谢谢!!

4

1 回答 1

1

原来是因为我在表单内使用了 modalPanel ...我将表单放在 modalPanel 之外,一切正常。

于 2012-09-27T18:00:04.233 回答