Uploaded image for project: 'Causeway'
  1. Causeway
  2. CAUSEWAY-691

In Wicket viewer, improve drop-down list's handling of null entity or values

    XMLWordPrintableJSON

Details

    Description

      Several issues:
      1. for entities, if the reference is null, the drop-down (EntityLinkSelect2Panel) always shows the first object in edit mode
      2. for value types (eg enums), it is not possible to set a null value

      ~~~
      To replicate (1) add the following property to the simple archetype's SimpleObject class:

      // //////////////////////////////////////
      // other (property)
      // //////////////////////////////////////

      private SimpleObject other;

      @Column(allowsNull="true")
      @MemberOrder(sequence = "1")
      // @Mandatory
      public SimpleObject getOther()

      { return other; }

      public void setOther(final SimpleObject other)

      { this.other = other; }

      public List<SimpleObject> choicesOther()

      { List<SimpleObject> list = container.allInstances(SimpleObject.class); return list; }

      ~~~
      To replicate (2),

      ToDoItem

      @javax.jdo.annotations.Column(allowsNull="true")
      public Subcategory getSubcategory() {

      and

      ToDoItemContributions

      public ToDoItem updateCategory(
      final ToDoItem item,
      final @Named("Category") Category category,
      final @Optional @Named("Subcategory") Subcategory subcategory)

      { ... }

      and

      public static enum Category {
      Professional {
      @Override
      public List<Subcategory> subcategories()

      { return Arrays.asList(null, Subcategory.OpenSource, Subcategory.Consulting, Subcategory.Education); }

      }, Domestic {
      @Override
      public List<Subcategory> subcategories()

      { return Arrays.asList(null, Subcategory.Shopping, Subcategory.Housework, Subcategory.Garden, Subcategory.Chores); }

      }, Other {
      @Override
      public List<Subcategory> subcategories()

      { return Arrays.asList(null, Subcategory.Other); }

      };

      public abstract List<Subcategory> subcategories();
      }

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: