2013-03-31 21 views
0

我嘗試使用JSF 2.2創建上載文件表單。 在這種形式中,我有bankCode輸入框,它會在丟失焦點時將ajax發送到服務器。 而且這個表格還包含輸入文件框。所以我必須把enctype =「multipart/form-data」屬性設置爲h:form標籤才能上傳文件。JSF 2.2 - 與多部分/表單數據形式的ajax有一些錯誤

每當我把enctype形成--ajax會在Chrome的debuger中顯示錯誤信息。

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> 

我怎樣才能解決這個錯誤。

+0

您的問題可能與我看到的一些潛在問題有關。 'onblur'javascript可能不會在'blur'ajax事件之前執行,或者'validateTextInput' javascript函數可能存在代碼問題。看到Javascript的代碼將告訴我們更多。 –

+0

JSF 2.2是否正式發佈?你應該期待錯誤,如果它沒有 – kolossus

回答

0

感謝您的回覆。 我發現這是JSF 2.2 M10到M12的錯誤。 我更改爲JSF 2.2 M9,它運行良好。

所以我會用M9直到JSF 2.2發佈。

+0

你有報告嗎?如果沒有,它不會進入最終版本。如果是這樣,請發佈報告鏈接。 – BalusC

+0

我仍然在gassfish4附帶的JSF 2.2版本版本中發現此錯誤。我嘗試谷歌幾個星期,但還沒有找到解決方案。請告訴我解決問題的方法。 –

0

我提出了一個錯誤Mojarra,我認爲這與你的問題有關。

Stackoverflow issue

PS。投票的Jira可能會加快解決方案,因爲它是從5月14日休眠