Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-5518

FormComponent.updateCollectionModel does not handle unmodifiableList

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 6.12.0
    • 7.0.0-M1, 6.15.0
    • None
    • None

    Description

      FormComponent.updateCollectionModel should handle situation, when getter returns unmodifiable list.

      Proposed solution:

      formComponent.modelChanging();
      booelan isChanged;
      try {
      collection.clear();
      if (convertedInput != null)

      { collection.addAll(convertedInput); }

      isChanged = true;
      catch (Exception e)

      { // ignore this exception as Unmodifiable list does not allow change logger.info("An error occurred while trying to modify list attached to " + formComponent, e); }

      try

      { if(isChanged) formComponent.getModel().setObject(collection); else // TODO: create here collection as non-abstract successor of setObject declared argument formComponent.getModel().setObject(new ArrayList(convertedInput)); isChanged = true; }

      catch (Exception e)

      { // ignore this exception because it could be that there // is not setter for this collection. logger.info("An error occurred while trying to set the new value for the property attached to " + formComponent, e); }

      // at least one update method should pass successfully
      if(isChanged)
      formComponent.modelChanged();
      else
      throw new RuntimeException("An error occurred while trying to modify value for the property attached to " + formComponent);

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            svenmeier Sven Meier
            petr.lancaric@lmc.eu Petr Lancaric
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment