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

New FormComponentUpdatingBehavior to replace wantOnSelectionChangedNotifications()

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 8.0.0-M4
    • Fix Version/s: 8.0.0-M6
    • Component/s: wicket
    • Labels:
      None

      Description

      Several form components support notification via normal HTTP request when their value changes in the browser:

      • CheckBox
      • DropDownChoice
      • RadioChoice
      • CheckGroup/Check
      • RadioGroup/Radio

      I propose to move support for this feature into a new behavior "FormComponentUpdatingBehavior".
      This has the following advantages:

      • having to override #wantOnSelectionChangedNotifications() for #onSelectionChanged() to be triggered wasn't very intuitive
      • we minimize the API of these components (the two methods above and #onRequest())
      • we can simplify these components by removing from them this non-core concern (a legacy from the pre-Ajax era)
      • to use the feature users can add a behavior instead, to have a notification triggered on that behavior (similar to AjaxFormChoiceComponentUpdatingBehavior)
      • can be used for text components too

      I reused IFormSubmitter to submit the form (for SubmitLink too) so we can simplify Form now:

      • no need for the hidden field "_hf_0", used to transport the actual listener url - the form's action is changed instead
      • no need for #dispatchEvent(), used to schedule another request handler that triggers the component
      • #getJsForInterfaceUrl() is greatly simplified (renamed to #getJsForListenerUrl() now)

      Migration effort is manageable:

      new CheckBox("id", model) {
      	protected boolean wantOnSelectionChangedNotifications() {
      		return true;
              }
      
      	protected void onSelectionChanged(Boolean newSelection) {
      		// do something, page will be rerendered;
      	}
      };
      

      ... becomes:

      new CheckBox("id", model)
      .add(new FormComponentUpdatingBehavior() {
      	protected void onSelectionChanged() {
      		// do something, page will be rerendered;
      	}
      });
      

        Issue Links

          Activity

          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 15573cabcf44768fe2631bb9b4b6dcf5e2b2e494 in wicket's branch refs/heads/WICKET-6348-selection-change from Sven Meier
          [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=15573ca ]

          WICKET-6348 use submitter instead of hidden field

          Show
          jira-bot ASF subversion and git services added a comment - Commit 15573cabcf44768fe2631bb9b4b6dcf5e2b2e494 in wicket's branch refs/heads/ WICKET-6348 -selection-change from Sven Meier [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=15573ca ] WICKET-6348 use submitter instead of hidden field
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 7f08fab8fa4ab9146fb0504222bb354a8dd98b46 in wicket's branch refs/heads/WICKET-6348-selection-change from Sven Meier
          [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=7f08fab ]

          WICKET-6348 move selection change into behavior

          Show
          jira-bot ASF subversion and git services added a comment - Commit 7f08fab8fa4ab9146fb0504222bb354a8dd98b46 in wicket's branch refs/heads/ WICKET-6348 -selection-change from Sven Meier [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=7f08fab ] WICKET-6348 move selection change into behavior
          Hide
          svenmeier Sven Meier added a comment -

          Additional benefit: No hidden <div> will appear any longer in a form iff no default button is set, no get parameters have to be rendered and no selection change notification is needed.

          Show
          svenmeier Sven Meier added a comment - Additional benefit: No hidden <div> will appear any longer in a form iff no default button is set, no get parameters have to be rendered and no selection change notification is needed.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 75ec362716674227817906d18c50d530f584041e in wicket's branch refs/heads/WICKET-6348-selection-change from Sven Meier
          [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=75ec362 ]

          WICKET-6348 added javadoc; #getUpdateModel(); restored example

          Show
          jira-bot ASF subversion and git services added a comment - Commit 75ec362716674227817906d18c50d530f584041e in wicket's branch refs/heads/ WICKET-6348 -selection-change from Sven Meier [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=75ec362 ] WICKET-6348 added javadoc; #getUpdateModel(); restored example
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 01d8cffb9f8ab3c957a4aa372b53644317d6a479 in wicket's branch refs/heads/WICKET-6348-selection-change from Sven Meier
          [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=01d8cff ]

          WICKET-6348 renamed to FormComponentUpdatingBehavior

          keep deprecated getJsForInterfaceUrl()

          Show
          jira-bot ASF subversion and git services added a comment - Commit 01d8cffb9f8ab3c957a4aa372b53644317d6a479 in wicket's branch refs/heads/ WICKET-6348 -selection-change from Sven Meier [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=01d8cff ] WICKET-6348 renamed to FormComponentUpdatingBehavior keep deprecated getJsForInterfaceUrl()
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit c52f15fcec4a23c06bdf3de1587d29e6f38fc289 in wicket's branch refs/heads/WICKET-6348-selection-change from Sven Meier
          [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=c52f15f ]

          WICKET-6348 small improvements

          • check host component type
          • getFormComponent() final
          • new onError()
          • support ListMultipleChoice
          Show
          jira-bot ASF subversion and git services added a comment - Commit c52f15fcec4a23c06bdf3de1587d29e6f38fc289 in wicket's branch refs/heads/ WICKET-6348 -selection-change from Sven Meier [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=c52f15f ] WICKET-6348 small improvements check host component type getFormComponent() final new onError() support ListMultipleChoice
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 387e41bd3acc96553733a51a3f72202949f69dc3 in wicket's branch refs/heads/WICKET-6348-selection-change from Sven Meier
          [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=387e41b ]

          WICKET-6348 guide update for FormComponentUpdatingBehavior

          Show
          jira-bot ASF subversion and git services added a comment - Commit 387e41bd3acc96553733a51a3f72202949f69dc3 in wicket's branch refs/heads/ WICKET-6348 -selection-change from Sven Meier [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=387e41b ] WICKET-6348 guide update for FormComponentUpdatingBehavior
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 36e8dcf60dd4a9eae3378fe523414c179cea03e8 in wicket's branch refs/heads/WICKET-6348-selection-change from Sven Meier
          [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=36e8dcf ]

          WICKET-6348 added javadoc and overridable #getEvent()

          Show
          jira-bot ASF subversion and git services added a comment - Commit 36e8dcf60dd4a9eae3378fe523414c179cea03e8 in wicket's branch refs/heads/ WICKET-6348 -selection-change from Sven Meier [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=36e8dcf ] WICKET-6348 added javadoc and overridable #getEvent()
          Hide
          svenmeier Sven Meier added a comment -

          This feature is now separated into FormComponentUpdatingBehavior.

          Show
          svenmeier Sven Meier added a comment - This feature is now separated into FormComponentUpdatingBehavior.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 7e1a89433ecbdbcc5a27435b665edf8bee4c6456 in wicket's branch refs/heads/WICKET-6105-java.time from Sven Meier
          [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=7e1a894 ]

          WICKET-6348 minor addition: update raw input when component is not contained in form
          this wasn't done in 7.x either, but for consistency the raw input should be updated, so it is available when a validation fails

          Show
          jira-bot ASF subversion and git services added a comment - Commit 7e1a89433ecbdbcc5a27435b665edf8bee4c6456 in wicket's branch refs/heads/ WICKET-6105 -java.time from Sven Meier [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=7e1a894 ] WICKET-6348 minor addition: update raw input when component is not contained in form this wasn't done in 7.x either, but for consistency the raw input should be updated, so it is available when a validation fails
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 9e028af34cc432ddbffd6e09e82bf46d6226c0c8 in wicket's branch refs/heads/master from Sven Meier
          [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=9e028af ]

          WICKET-6348 minor addition: update raw input when component is not contained in form
          this wasn't done in 7.x either, but for consistency the raw input should be updated, so it is available when a validation fails

          Show
          jira-bot ASF subversion and git services added a comment - Commit 9e028af34cc432ddbffd6e09e82bf46d6226c0c8 in wicket's branch refs/heads/master from Sven Meier [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=9e028af ] WICKET-6348 minor addition: update raw input when component is not contained in form this wasn't done in 7.x either, but for consistency the raw input should be updated, so it is available when a validation fails

            People

            • Assignee:
              svenmeier Sven Meier
              Reporter:
              svenmeier Sven Meier
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development