Uploaded image for project: 'Click'
  1. Click
  2. CLK-1

Multipart form parameters not available during Page.onInit()

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • None
    • Click 0.10

    Description

      Hi folks, I ran across an issue with composite pages and multipart forms.

      Scenario:

      • a page that contains a single panel
      • all concrete panels contain a form. In most cases - a regular form; in some cases - multipart form with image upload.
      • actual panel class is determined inside "Page.onInit()" depending on a combination of request parameters.
      • Parameters are read via "context.getRequestParameter(..)"

      Problem:

      The above works for regular forms, but doesn't work for multipart forms, as multipart form data is only processed after onInit() during control processing phase when it is too late to determine what panel to display.

      Current Workaround:

      Currently I am reading multipart data via FileUpload inside Page.onInit() and save it in the context via getContext().setMultiPartFormData(..). later I use a subclass of Form that overrides onprocess:

      public boolean onProcess() {

      // handle preprocessed multipart
      if (!getContext().getMultiPartFormData().isEmpty())

      { // do the same thing super does, but skip multipart checks ..... }

      else

      { return super.onProcess(); }

      }

      I think for consistency Click should process multipart data before onInit(..) so that context.getRequestParameter(..) would work the same way for all types of forms. I am not that intimately familiar with Apache FIleUpload framework to tell whether this would break current FileField logic ... but we need to handle this in some way.

      Thanks
      Andrus

      Attachments

        Activity

          People

            medgar Malcolm Edgar
            andrus Andrus Adamchik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: