[英]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。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.