Wicket
  1. Wicket
  2. WICKET-2267

Type safe component path support for listviews, improve coding efficiency by 60%

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Later
    • Affects Version/s: 1.4-RC2
    • Fix Version/s: None
    • Component/s: wicket
    • Labels:
      None

      Description

      I suggest that the following methods be added into formTester:

      1. formTester.setValue(Component component, String value); // Instead of just the String path version

      2. formTester.submit(IFormSubmittingComponent button (or suitable superclass)); // Instead of just the String path version

      Furthermore, I suggest incorporating the following abstract ListView implementation:

      public abstract class TestableListView<ListItemType extends ListItem<ItemType>, ItemType> extends ListView<ItemType> {
      public TestableListView(String id, IModel<List<ItemType>> model)

      { super(id, model); }

      public TestableListView(String id, List<ItemType> list)

      { super(id, list); }

      public TestableListView(String id)

      { super(id); }

      @Override
      protected final void populateItem(ListItem<ItemType> item)

      { // do nothing here }

      @Override
      protected abstract ListItemType newItem(int index);

      @Override
      public Iterator<ListItemType> iterator()

      { return (Iterator<ListItemType>) super.iterator(); }

      }

      For more details, see attached quickstart.

      1. Wicket-Quickstart.zip
        113 kB
        Martin Makundi

        Activity

        Hide
        Martin Grigorov added a comment -

        Resolution: Later

        Closing as "Later" because there was no interest in this functionality for 4 years now.

        Show
        Martin Grigorov added a comment - Resolution: Later Closing as "Later" because there was no interest in this functionality for 4 years now.
        Hide
        Martin Makundi added a comment -

        > What is difference to setFormComponentValue and setFormSubmittingComponentValue??

        I do not know what you mean. This issue concentrates on promoting using live component paths instead of hardcoded string paths to components.

        Instead of "panel:listview:0:component" prefer using panel.getListView().getListItems().get(0).getMyComponent().getPageRelativePath();

        Currently listitem is anonymous so it is not possible. Using TestableList view the listItem becomes a real class and its getMyComponent can be accessed reasonably.

        Show
        Martin Makundi added a comment - > What is difference to setFormComponentValue and setFormSubmittingComponentValue?? I do not know what you mean. This issue concentrates on promoting using live component paths instead of hardcoded string paths to components. Instead of "panel:listview:0:component" prefer using panel.getListView().getListItems().get(0).getMyComponent().getPageRelativePath(); Currently listitem is anonymous so it is not possible. Using TestableList view the listItem becomes a real class and its getMyComponent can be accessed reasonably.
        Hide
        Juergen Donnerstag added a comment -

        What is difference to setFormComponentValue and setFormSubmittingComponentValue??

        Show
        Juergen Donnerstag added a comment - What is difference to setFormComponentValue and setFormSubmittingComponentValue??
        Hide
        Martin Makundi added a comment -

        In my opinnion, this results in very clean code.

        Show
        Martin Makundi added a comment - In my opinnion, this results in very clean code.
        Hide
        Martin Makundi added a comment -

        The attached quickstart does not compile (by default) without the new features.

        However, it can be run by commenting in and out the "TODO New feature request" lines):

        switch the comments of:

        { formTester.setValue(bookItems.get(1).getAuthorField(), "Hemingway"); // TODO New feature request // tester.getServletRequest().setParameter(bookItems.get(1).getAuthorField().getInputName(), "Hemingway"); }

        and

        { formTester.submit(bookForm.getSubmitButton()); // TODO New feature request // formTester.submit(); }
        Show
        Martin Makundi added a comment - The attached quickstart does not compile (by default) without the new features. However, it can be run by commenting in and out the "TODO New feature request" lines): switch the comments of: { formTester.setValue(bookItems.get(1).getAuthorField(), "Hemingway"); // TODO New feature request // tester.getServletRequest().setParameter(bookItems.get(1).getAuthorField().getInputName(), "Hemingway"); } and { formTester.submit(bookForm.getSubmitButton()); // TODO New feature request // formTester.submit(); }

          People

          • Assignee:
            Unassigned
            Reporter:
            Martin Makundi
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 5h
              5h
              Remaining:
              Remaining Estimate - 5h
              5h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development