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

Multipart form parameters not available during Page.onInit()

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      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

        Activity

        Hide
        medgar Malcolm Edgar added a comment -

        Hi Andrus,

        I think we could have the Context object to some preprocessing of the multipart data if not already done by the Form to help out in these situations. I will take a crack at this over the weekend.

        regards Malcolm Edgar

        Show
        medgar Malcolm Edgar added a comment - Hi Andrus, I think we could have the Context object to some preprocessing of the multipart data if not already done by the Form to help out in these situations. I will take a crack at this over the weekend. regards Malcolm Edgar
        Hide
        medgar Malcolm Edgar added a comment -

        Fixed in release 0.12

        Show
        medgar Malcolm Edgar added a comment - Fixed in release 0.12

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development