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

Allow enums to implement interfaces for choices.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.17.0
    • Fix Version/s: 1.18.0
    • Component/s: Core, Core: Viewer: Wicket
    • Labels:
      None

      Description

      The code we wanted to write was equivalent to:

          public Object act(
                  final INflLeague nflLeague,
                  final NflRegion nflRegion,
                  final NflTeamEntity nflTeam) {
              nflPlayer.updateUsingEntity((NflLeague)nflLeague, nflRegion, nflTeam);
              return this.nflPlayer;
          }
      
          public List<? extends INflLeague> choices0Act() {
              return Arrays.asList(NflLeague.values());
          }
          ...
      
      

      where NflLeague is an enum that implements INflLeague :

      public interface INflLeague {
          String getName();
      }
      

      and

      public enum NflLeague implements INflLeague {
          AFC,
          NFC;
      
          @Override
          public String getName() {
              return name();
          }
      }
      

      There are two issues:

      • first, in the metamodel we don't introspect enums to recognise that a list of NflLeague enum instances can be returned in the choices method returning List<INflLeague>
      • second, in the Wicket viewer the selection of the choicesPanel is based on the type, and if an interface is used then it guesses a referencePanel rather than ValueSelect2Panel that is normally used for enums. The marshalling logic for ReferencePanel assumes entities, and fails when handed a bunch of scalar enums.

        Attachments

          Activity

            People

            • Assignee:
              danhaywood Daniel Keir Haywood
              Reporter:
              danhaywood Daniel Keir Haywood
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: