[英]JSF 2.2 - ajax in form with multipart/form-data has some error
I try to create upload file form with JSF 2.2. 我尝试使用JSF 2.2创建上传文件表单。 In this form I have bankCode input box that will ajax to server when loss focus.
在这种形式中,我有bankCode输入框,当丢失焦点时,该框将与服务器对齐。 And this form also contain input file box with.
而且此表格还包含输入文件框。 SO I must put enctype="multipart/form-data" attribute to h:form tag for upload file.
因此,我必须将enctype =“ multipart / form-data”属性放入h:form标记以上传文件。
Everytime I put enctype to form - the ajax will show error message in Chrome's debuger. 每当我将enctype放入表单时,ajax都会在Chrome的调试器中显示错误消息。
Uncaught TypeError: Cannot read property 'length' of null
未捕获的TypeError:无法读取null的属性“长度”
jsf.js.htm:359jsf.js.htm:359
Example code 范例程式码
<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>
How can I fix this error. 如何解决此错误。
Thanks for reply. 谢谢你的答复。 I found that this is bug of JSF 2.2 M10 to M12.
我发现这是JSF 2.2 M10到M12的错误。 I change to JSF 2.2 M9, it work well.
我更改为JSF 2.2 M9,它运行良好。
So I will use M9 untill JSF 2.2 is released. 因此,在JSF 2.2发布之前,我将使用M9。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.