Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2572

Duplicate properties in bean model

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 5.4.1
    • None
    • beanmodel
    • None

    Description

      If you create a BeanModel for a class with a private field that has the same name as a getter method, you end up with two properties:

      package org.example;
      
      import java.util.Collections;
      import java.util.Locale;
      
      import org.apache.tapestry5.beaneditor.BeanModel;
      import org.apache.tapestry5.beaneditor.BeanModelSourceBuilder;
      import org.apache.tapestry5.internal.services.MapMessages;
      import org.apache.tapestry5.services.BeanModelSource;
      
      public class Foo {
      
        private boolean isBar;
      
        public boolean isBar() {
          return isBar;
        }
      
        public static void main(final String[] args) {
          BeanModelSource bms = new BeanModelSourceBuilder().build();
          BeanModel<Foo> model = bms.createDisplayModel(Foo.class, new MapMessages(Locale.US, Collections.emptyMap()));
          System.out.println(model.getPropertyNames());
        }
      
      }
      

      The output is {{ [bar, isBar] }}

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jkemnade Jochen Kemnade
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: