Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Input file validation errors are not clearable

vijai-OracleMay 4 2015 — edited May 5 2015

Hi,

     I have a small use case where I have a inputfile and during upload I validate the file in the inputFile validator and reset the content.

In the validator, first I reset the file and I throw the ValidatorException, say for "file type not valid", So the thrown exception is shown in a bubble around the inputFile component and its content is also reset.

Now since the inputFile is reset, I expect a required exception when I simply press the submit button. But I instead get the same exception thrown before, The code is as follows,

JAVA

    public void validator(FacesContext facesContext, UIComponent uIComponent,

                          Object object) {

        inputFile.resetValue();

        inputFile.setValid(false);

        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "File type is not valid"));

    }

JSPX

<af:form id="f1" usesUpload="true" defaultCommand="cb1">

        <af:inputFile label="Label 1" id="if1"

                      binding="#{pageFlowScope.SampleBean.inputFile}"

                      required="true"

                      validator="#{pageFlowScope.SampleBean.validator}"/>

        <af:commandButton text="submit" id="cb1" partialSubmit="false"/>

      </af:form>

I am using jdev 11.1.1.7

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 2 2015
Added on May 4 2015
16 comments
445 views