JSF 2.2로 파일 업로드 양식을 만들려고합니다. 이 양식에서는 손실 초점 때 서버에 아약스 할 bankCode 입력 상자가 있습니다. 또한이 양식에는 입력 파일 상자가 들어 있습니다. 그래서 업로드 파일을위한 h : form 태그에 enctype = "multipart/form-data"속성을 넣어야합니다.JSF 2.2 - 다중 파트/양식 데이터가있는 양식의 아약은 약간의 오류가 있습니다.
언제든지 양식에 enctype을 입력합니다. Chrome 디버거에 ajax가 오류 메시지를 표시합니다.
Uncaught TypeError: Cannot read property 'length' of 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>
어떻게이 오류를 해결할 수 있습니다.
문제점은 내가 볼 수있는 여러 잠재적 문제와 관련이있을 수 있습니다. 'onblur' 자바 스크립트는'blur' ajax 이벤트 전에 실행되지 않았거나'validateTextInput' 자바 스크립트 함수에 코드 문제가있을 수 있습니다. Javascript 코드를 보면 더 많은 정보를 얻을 수 있습니다. –
JSF 2.2가 공식적으로 출시 되었습니까? 그것이 없다면 버그를 예상해야합니다 – kolossus