Uploaded image for project: 'Isis'
  1. Isis
  2. ISIS-996

Not possible to "replace" components in Wicket viewer (workaround is to use "add")

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: viewer-wicket-1.7.0
    • Fix Version/s: 2.7.0
    • Component/s: Core: Viewer: Wicket
    • Labels:
      None

      Description

      As per http://isis.markmail.org/thread/x3k2www3m2wfsgtv

      To recreate:

      • copy ReferencePanelFactory to ReferencePanelFactory2

      in (subclass of) IsisWicketApplication, add:

          @com.google.inject.Singleton
          public static class MyComponentFactoryRegistrar extends ComponentFactoryRegistrarDefault {
      
              @Override
              public void addComponentFactories(ComponentFactoryList componentFactories) {
                  super.addComponentFactories(componentFactories);
                  componentFactories.replace(new ReferencePanelFactory2());
              }
          }
      

      and

              final Module overrides = new AbstractModule() {
                  @Override
                  protected void configure() {
                       ...
                      bind(ComponentFactoryRegistrar.class).
                          to(MyComponentFactoryRegistrar.class);
                  }
              };
      

      the issue is that "replace" ends up replacing all component factories of type ComponentType.SCALAR_NAME_AND_VALUE, whereas it should instead just replace the one for ReferencePanelFactory.

      The workaround is easy enough: call "add" (which puts new factory at beginning of list) rather than "replace".

        Activity

        Hide
        bibryam Bilgin Ibryam added a comment -

        For my custom footer I still had to use replace rather than add in order to make it work.

        Show
        bibryam Bilgin Ibryam added a comment - For my custom footer I still had to use replace rather than add in order to make it work.
        Hide
        mgrigorov Martin Grigorov added a comment -

        org.apache.isis.viewer.wicket.ui.app.registry.ComponentFactoryRegistrar.ComponentFactoryList uses an ArrayList, and ArrayList#add() appends, so there must be something else that makes it work.

        ComponentFactoryRegistrar.ComponentFactoryList#insert(0, componentFactory) would prepend.

        Show
        mgrigorov Martin Grigorov added a comment - org.apache.isis.viewer.wicket.ui.app.registry.ComponentFactoryRegistrar.ComponentFactoryList uses an ArrayList, and ArrayList#add() appends, so there must be something else that makes it work. ComponentFactoryRegistrar.ComponentFactoryList#insert(0, componentFactory) would prepend.

          People

          • Assignee:
            Unassigned
            Reporter:
            danhaywood Dan Haywood
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:

              Development