3 Replies Latest reply on Dec 10, 2008 10:32 AM by Jan Frederik Naujoks

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

    Jan Frederik Naujoks Newbie

      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 name="controls">
      <h:commandLink value="#{common.Close}" style="cursor:pointer" onclick="Richfaces.hideModalPanel('addPanel')" />
      <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>
      <h:panelGrid columns="1">
      <h:outputText value="#{common.upload_file}:" styleClass="bold-blue"></h:outputText>
      <rich:fileUpload allowFlash="false"
      <a4j:support actionListener="#{documentDirectoryTreeDAO.actionClearFile}" event="onclear" reRender="uploadFile" immediate="true"></a4j:support>
      <h:outputText value="#{common.title}:" styleClass="bold-blue"></h:outputText>
      <t:div style="float: right;" styleClass="saveDiv">
      <a4j:commandButton value="#{common.save}" actionListener="#{documentDirectoryTreeDAO.actionSaveDocument}" reRender="documents" oncomplete="closePanel('addPanelForm', 'addPanel', 'addPanelMessages');" />
      <t:div style="float: left;" styleClass="abortDiv">
      <a4j:commandButton value="#{common.cancel}" onclick="Richfaces.hideModalPanel('addPanel')" />

      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. ;)