3 Replies Latest reply on Dec 10, 2008 10:32 AM by jfn

    rich:fileUpload in rich:modalPanel: required="true" not work

    jfn

      hi, I am trying to use the rich:fileUpload component inside a rich:modalPanel. so far all worked well. But I ran into a major problem: I set required to true in the rich:fileUpload, but the form submits without an error even if no file is uploaded/in the list.

      some code:


      <rich:modalPanel id="addPanel" width="600" height="530" rendered="#{accountDAO.loggedIn}" style="overflow: auto;">
      <f:facet name="header">
      <h:outputText value="#{common.add_document}" />
      </f:facet>
      <f:facet name="controls">
      <h:form>
      <h:commandLink value="#{common.Close}" style="cursor:pointer" onclick="Richfaces.hideModalPanel('addPanel')" />
      </h:form>
      </f:facet>
      <a4j:form id="addPanelForm" enctype="multipart/form-data" ajaxSubmit="true" ajaxSingle="true" >
      <h:inputHidden value=""></h:inputHidden>
      <a4j:outputPanel ajaxRendered="true">
      <h:messages id="addPanelMessages" styleClass="errors"></h:messages>
      </a4j:outputPanel>
      <h:panelGrid columns="1">
      <h:panelGroup>
      <h:outputText value="#{common.upload_file}:" styleClass="bold-blue"></h:outputText>
      </h:panelGroup>
      <h:panelGroup>
      <rich:fileUpload allowFlash="false"
      fileUploadListener="#{documentDirectoryTreeDAO.uploadListener}"
      id="uploadFile"
      immediateUpload="true"
      maxFilesQuantity="1"
      required="true"
      listHeight="65"
      listWidth="510"
      requiredMessage="test"
      uploadData="#{documentDirectoryTreeDAO.uploadedFiles}">
      <a4j:support actionListener="#{documentDirectoryTreeDAO.actionClearFile}" event="onclear" reRender="uploadFile" immediate="true"></a4j:support>
      </rich:fileUpload>
      </h:panelGroup>
      <h:panelGroup>
      <h:outputText value="#{common.title}:" styleClass="bold-blue"></h:outputText>
      </h:panelGroup>
      </h:panelGrid>
      <t:div style="float: right;" styleClass="saveDiv">
      <a4j:commandButton value="#{common.save}" actionListener="#{documentDirectoryTreeDAO.actionSaveDocument}" reRender="documents" oncomplete="closePanel('addPanelForm', 'addPanel', 'addPanelMessages');" />
      </t:div>
      <t:div style="float: left;" styleClass="abortDiv">
      <a4j:commandButton value="#{common.cancel}" onclick="Richfaces.hideModalPanel('addPanel')" />
      </t:div>
      </a4j:form>
      </rich:modalPanel>

      a few notes: I tried it the enctype="multipart/form-data", same result.
      Same result with immediateUpload="false".
      uploadData="#{documentDirectoryTreeDAO.uploadedFiles}" is:
      private List uploadedFiles = null;
      no change in behavior when initializing the list with an empty ArrayList.

      I can catch the "no file in my bean" case in the action that submits the form, but I would like to have the required message to pop up along with all the other required messages from that form (theres more inputs in it).

      Thanks for any advice, and if I experience "normal" or intended behavior it would be nice if someone would update the docs. ;)