You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by "Daniel Keir Haywood (Jira)" <ji...@apache.org> on 2020/03/19 10:58:00 UTC

[jira] [Updated] (ISIS-2107) Allow enums to implement interfaces for choices (also fixed in "v1 maintenance")

     [ https://issues.apache.org/jira/browse/ISIS-2107?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Keir Haywood updated ISIS-2107:
--------------------------------------
    Summary: Allow enums to implement interfaces for choices (also fixed in "v1 maintenance")  (was: Allow enums to implement interfaces for choices.)

> Allow enums to implement interfaces for choices (also fixed in "v1 maintenance")
> --------------------------------------------------------------------------------
>
>                 Key: ISIS-2107
>                 URL: https://issues.apache.org/jira/browse/ISIS-2107
>             Project: Isis
>          Issue Type: Bug
>          Components: Core, Viewer: Wicket
>    Affects Versions: 1.17.0
>            Reporter: Daniel Keir Haywood
>            Assignee: Daniel Keir Haywood
>            Priority: Minor
>             Fix For: v1 maintenance, 2.0.0-M3
>
>
> The code we wanted to write was equivalent to:
> {code:java}
>     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());
>     }
>     ...
> {code}
> where NflLeague is an enum that implements INflLeague :
> {code:java}
> public interface INflLeague {
>     String getName();
> }
> {code}
> and
> {code:java}
> public enum NflLeague implements INflLeague {
>     AFC,
>     NFC;
>     @Override
>     public String getName() {
>         return name();
>     }
> }
> {code}
> 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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)