Announcement Announcement Module
Collapse
No announcement yet.
[bug] jsf managed bean generation fail (because of bad collection naming strategies?) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [bug] jsf managed bean generation fail (because of bad collection naming strategies?)

    I always tend to name my collection instance variable names after their type (e.g. Set<Address> addressSet = new HashSet<Address>(); ) instead of using a plural "-es" like suffix, which I think has a lot less sense (e.g. because of the nesting possibilities of groups).

    A while ago I was astonished to notice Spring using the plural suffix naming strategy for generating names, as it doesn't feel like good practice, and now I stumbled upon bugs I think are caused by this strategy.

    My domain model object:
    Code:
    @RooJavaBean
    @RooToString
    @RooJpaActiveRecord
    public class Person extends AbstractEntity {
    
        private String firstName;
    
        private String name;
    
        private String initials;
    
        @ManyToOne
        private Nationality nationality;
    
        @ManyToMany(cascade = CascadeType.ALL)
        private Set<TradLanguage> languagueSet = new HashSet<TradLanguage>();
    
        @ManyToMany(cascade = CascadeType.ALL)
        private Set<Address> addressSet = new HashSet<Address>();
    
        @ManyToMany(cascade = CascadeType.ALL)
        private Set<PhoneNr> phoneNrSet = new HashSet<PhoneNr>();
    }
    generated PersonBean_Roo_ManagedBean.aj contains non-existing method names:

    Code:
        public java.lang.String PersonBean.onEdit() {
            if (person != null && person.getTradLanguages() != null) {
                selectedLanguagueSet = new ArrayList<TradLanguage>(person.getLanguagueSet());
            }
            if (person != null && person.getAddresses() != null) {
                selectedAddressSet = new ArrayList<Address>(person.getAddressSet());
            }
            if (person != null && person.getPhoneNrs() != null) {
                selectedPhoneNrSet = new ArrayList<PhoneNr>(person.getPhoneNrSet());
            }
            return null;
        }
    and

    Code:
       
        public void CompanyBean.reset() {
            company = null;
            selectedTradLanguages = null;
            selectedAddresses = null;
            selectedPhoneNrs = null;
            createDialogVisible = false;
        }
    while the declarations read:

    Code:
        private List<TradLanguage> CompanyBean.selectedLanguagueSet;
        
        private List<Address> CompanyBean.selectedAddressSet;
        
        private List<PhoneNr> CompanyBean.selectedPhoneNrSet;
    So the method names in red are generated incorrectly as opposed by the green method names.

    Do I create a Jira for this?

    Best wishes,

    Jochen

    EDIT: I've found a similar though different code generation issue:

    In my model I have 2 collections of street objects:
    Code:
        @ManyToMany(cascade = CascadeType.ALL)
        private Set<Street> rightfulStreets = new HashSet<Street>();
    
        @ManyToMany(cascade = CascadeType.ALL)
        private Set<Street> parkStreets = new HashSet<Street>();
    in the generated xxxBean_Roo_ManagedBean.aj it correctly generated:

    Code:
        private List<Street> AreaBean.selectedRightfulStreets;
        
        private List<Street> AreaBean.selectedParkStreets;
    though in these places it fails:

    Code:
    public void AreaBean.reset() {
            area = null;
            selectedStreets = null;
            selectedStreets = null;
            createDialogVisible = false;
        }
    and

    Code:
        public java.lang.String AreaBean.onEdit() {
            if (area != null && area.getStreets() != null) {
                selectedRightfulStreets = new ArrayList<Street>(area.getRightfulStreets());
            }
            if (area != null && area.getStreets() != null) {
                selectedParkStreets = new ArrayList<Street>(area.getParkStreets());
            }
            return null;
        }
    Last edited by Dr.Drane; Nov 28th, 2011, 11:42 AM. Reason: added similar issue

  • #2
    Raise an issue but please attach a Roo script to reproduce so I can reproduce it.

    Comment


    • #3
      done!

      https://jira.springsource.org/browse/ROO-2940

      Comment


      • #4
        Resolved
        Alan

        Comment

        Working...
        X