ICEfaces
  1. ICEfaces
  2. ICE-6203

ACE fileEntry custom validation

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-Beta2
    • Fix Version/s: 2.0.0
    • Component/s: ACE-Components
    • Labels:
      None
    • Environment:
      ACE
    • Affects:
      Documentation (User Guide, Ref. Guide, etc.), Sample App./Tutorial

      Description

      Add convenience method in FileInfo for marking a file upload as invalid, with a custom FileEntryStatus, which will also mark the FacesContext as invalid [ validationFailed() and possibly renderResponse() ]. Then the fileEntryListener can do customer validation on successfully uploaded files, such as stating that their contents are invalid.

        Activity

        Hide
        Mark Collette added a comment -
        • Added method to FileInfo to update it's status, fail the lifecycle and delete the uploaded file. Documented that if immediate=false, then it's too late to fail the lifecycle.
        • Noted that FacesMessages are generated before the fileEntryListener, so for the update method to have visual effect, needed to redesign when FacesMessages are added. It used to happen on decode, whether new results or not, so the FacesMessages would continue to display until the next upload operation. Now, we need to add the FacesMessages some time after the fileEntryListener is invoked, which if it's done right after event broadcasting would tie the adding to only the upload lifecycle, so they would not display as long. An alternative, for greater backwards compatibility, would be to always add them PreRender, after any fileEntryListener may be invoked. Or to always add file events, which will always add FacesMessages, but which have a flag for optionally invoking the listener first, only if an upload happened this lifecycle. Temporarily sided with only adding FacesMessages on upload lifecycle, since limited feedback was that anything else would be unnecessary and redundant. In comp team meeting agreed that for better compatibility with compat components, which do partial submits, would retain older behaviour of always re-adding FacesMessages, on every execute, using the technique of always queuing events, which are flagged to conditionally invoke the listener.
        • Added default validation, which happens in decode, before any possible custom validation, where if any files failed, then fail the lifecycle. This makes it impossible to unfail a file, which makes sense, since the file would have already been deleted anyway. This stops UpdateModel phase from happening, but still invokes the fileEntryListener.
        • Custom validation was not reflecting in results, investigation showed it was because apps are getting cloned results. Decided to not clone, since results can be ValueExpression, and in bean anyway. Documented that applications should save clones of FileEntryResults or FileInfo objects.
        • Fixed issue with ace-test where old icepush configuration in web.xml was keeping fileEntry progress from working. Really confused things, when ace-showcase was working, but ace-test was not.
        • Regression of sorts, where when file has completed uploading, fileEntry CSS state remains uploading, not complete. Possibly try unregistering push notifications in 100% progress one. No, that's before the JSF lifecycle has really ran, the difference between 100% progress and complete is quite useful. Just remembered that icepush.jar was updated, that might be it. Reverted to the Beta1 version of icepush.jar, but that didn't change anything. Added code to progress handler to not apply progress after switched to complete state. That fixed it.
        • Testing procedures described, and test ui provided, in form16 of: icefaces2/ace/test/web/fileEntry.xhtml

        Component changes
        Subversion 23595

        Test and example app changes
        Subversion 23596

        Show
        Mark Collette added a comment - Added method to FileInfo to update it's status, fail the lifecycle and delete the uploaded file. Documented that if immediate=false, then it's too late to fail the lifecycle. Noted that FacesMessages are generated before the fileEntryListener, so for the update method to have visual effect, needed to redesign when FacesMessages are added. It used to happen on decode, whether new results or not, so the FacesMessages would continue to display until the next upload operation. Now, we need to add the FacesMessages some time after the fileEntryListener is invoked, which if it's done right after event broadcasting would tie the adding to only the upload lifecycle, so they would not display as long. An alternative, for greater backwards compatibility, would be to always add them PreRender, after any fileEntryListener may be invoked. Or to always add file events, which will always add FacesMessages, but which have a flag for optionally invoking the listener first, only if an upload happened this lifecycle. Temporarily sided with only adding FacesMessages on upload lifecycle, since limited feedback was that anything else would be unnecessary and redundant. In comp team meeting agreed that for better compatibility with compat components, which do partial submits, would retain older behaviour of always re-adding FacesMessages, on every execute, using the technique of always queuing events, which are flagged to conditionally invoke the listener. Added default validation, which happens in decode, before any possible custom validation, where if any files failed, then fail the lifecycle. This makes it impossible to unfail a file, which makes sense, since the file would have already been deleted anyway. This stops UpdateModel phase from happening, but still invokes the fileEntryListener. Custom validation was not reflecting in results, investigation showed it was because apps are getting cloned results. Decided to not clone, since results can be ValueExpression, and in bean anyway. Documented that applications should save clones of FileEntryResults or FileInfo objects. Fixed issue with ace-test where old icepush configuration in web.xml was keeping fileEntry progress from working. Really confused things, when ace-showcase was working, but ace-test was not. Regression of sorts, where when file has completed uploading, fileEntry CSS state remains uploading, not complete. Possibly try unregistering push notifications in 100% progress one. No, that's before the JSF lifecycle has really ran, the difference between 100% progress and complete is quite useful. Just remembered that icepush.jar was updated, that might be it. Reverted to the Beta1 version of icepush.jar, but that didn't change anything. Added code to progress handler to not apply progress after switched to complete state. That fixed it. Testing procedures described, and test ui provided, in form16 of: icefaces2/ace/test/web/fileEntry.xhtml Component changes Subversion 23595 Test and example app changes Subversion 23596
        Hide
        Krashan Brahmanjara added a comment -

        I suppose it doesn't working now with icefaces 3.3 from trunk.

        Custom FileEntryStatus added to fileEntryListener are not displayed. Only generic FileEntryStatuses are visible.

        Sample code
        if (!allowEmptyFile)

        { //this message will be visible on screen file.updateStatus(FileEntryStatuses.UNKNOWN_SIZE, true, true); }

        if (useFileChecker)

        { //this custom message will not be visible on screen file.updateStatus(new InvalidContentFileStatus(), true, true); }
        Show
        Krashan Brahmanjara added a comment - I suppose it doesn't working now with icefaces 3.3 from trunk. Custom FileEntryStatus added to fileEntryListener are not displayed. Only generic FileEntryStatuses are visible. Sample code if (!allowEmptyFile) { //this message will be visible on screen file.updateStatus(FileEntryStatuses.UNKNOWN_SIZE, true, true); } if (useFileChecker) { //this custom message will not be visible on screen file.updateStatus(new InvalidContentFileStatus(), true, true); }
        Hide
        Krashan Brahmanjara added a comment -

        Sorry. My mistake. Above scenario works.

        Show
        Krashan Brahmanjara added a comment - Sorry. My mistake. Above scenario works.

          People

          • Assignee:
            Mark Collette
            Reporter:
            Mark Collette
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: