簡體   English   中英

JSF 2.2-具有multipart / form-data的Ajax表單存在一些錯誤

[英]JSF 2.2 - ajax in form with multipart/form-data has some error

我嘗試使用JSF 2.2創建上傳文件表單。 在這種形式中,我有bankCode輸入框,當丟失焦點時,該框將與服務器對齊。 而且此表格還包含輸入文件框。 因此,我必須將enctype =“ multipart / form-data”屬性放入h:form標記以上傳文件。

每當我將enctype放入表單時,ajax都會在Chrome的調試器中顯示錯誤消息。

未捕獲的TypeError:無法讀取null的屬性“長度”
jsf.js.htm:359

范例程式碼

<h:form id="dialogForm" prependId="false" enctype="multipart/form-data">
        <h:commandLink action="#{bankController.initCreate()}" class="btn add" style="margin: 10px 0 20px 20px;">
            <f:ajax immediate="true" execute="@this" render=":dialogForm"/>
            <span>Add new bank</span>
        </h:commandLink>
        <table class="dialogTable" style="margin: 10px 0 20px 20px;">
            <colgroup>
                <col width="30%"/>
                <col width="70%"/>
            </colgroup>
            <tr>
                <td class="label">
                    <label for="abbreviation">Bank's code<span class="required">*</span></label>
                </td>
                <td>                                           
                    <h:panelGroup id="codeBox" layout="block" class="codeBox">
                        <h:inputText id="code" value="#{bankController.curBank.code}" maxlength="10" class="input code #{bankController.isExistCode?'error':''}"
                                     onblur="return validTextInput('code',2);">
                        <f:validateLength minimum="2" maximum="10"/>
                            <f:ajax execute="@this" event="blur" listener="#{bankController.existCode()}" onevent="function(e){showValidateIcon(e, 'code');}" render="codeBox"/>
                        </h:inputText>
                        <span class="append2">
                            <img id="codeXLoad" src="#{cdnLocator.officeUrl}/img/load16.gif" title="On process, please wait" width="16" height="16" style="margin-top: 2px; display: none;"/>
                            <img id="codeXWarn" src="#{cdnLocator.officeUrl}/css/images/error_msg_icon.gif" title="Not allowed" width="16" height="16" style="margin-top: 2px; #{bankController.isExistCode?'':'display: none;'}"/>
                            <img id="codeXAvai" src="#{cdnLocator.officeUrl}/css/images/success_msg_icon.gif" title="Allowed" width="16" height="16" style="margin-top: 2px; #{bankController.isExistCode?'display: none;':''}"/>
                        </span>
                    </h:panelGroup>  
                </td>
            </tr>
            <tr>
                <td class="label">
                    <label for="icon">Bank icon file*</label>
                </td>
                <td>
                    <h:inputFile id="bankIconFile" value="#{bankController.bankIconFile}"/>
                </td>
            </tr>
        </table>
    </h:form>

如何解決此錯誤。

謝謝你的答復。 我發現這是JSF 2.2 M10到M12的錯誤。 我更改為JSF 2.2 M9,它運行良好。

因此,在JSF 2.2發布之前,我將使用M9。

我提出了Mojarra的錯誤,我認為這也與您的問題有關。

堆棧溢出問題

PS。 自5月14日起休眠,為吉拉投票可能會加快分辨率

暫無
暫無

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

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