This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 236373 - Code completion should check BeanInfo class for properties
Summary: Code completion should check BeanInfo class for properties
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: Expression Language (show other bugs)
Version: 7.3.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Martin Fousek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-25 14:09 UTC by bugmenot1
Modified: 2016-07-07 08:52 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bugmenot1 2013-09-25 14:09:08 UTC
I have a Bean like

@Dependent
@Named
public class ViewDirectory {
  private static final View LOGIN = new View("/login");
}

Using NetBeans to generate a getter for the properties generates static getters, which is fine. I created a BeanInfo class to expose static getters like this:

public class ViewDirectoryBeanInfo extends SimpleBeanInfo {

    @Override
    public PropertyDescriptor[] getPropertyDescriptors() {
        final List<PropertyDescriptor> descriptors = new ArrayList<>();
        for (final Method method : CLASS.getMethods()) {
            if (method.getGenericParameterTypes().length > 0) {
                continue;
            }
            final String name = method.getName();
            for (final String prefix : new String[]{"get", "is"}) {
                if (!name.startsWith(prefix)) {
                    continue;
                }
                final String propertyName = Introspector.decapitalize(name.substring(prefix.length()));
                try {
                    descriptors.add(new PropertyDescriptor(propertyName, method, null));
                } catch (IntrospectionException ex) {
                    throw new RuntimeException(ex);
                }
            }
        }
        return descriptors.toArray(new PropertyDescriptor[descriptors.size()]);
    }
}

Together I can use the bean to reference my JSF views in EL:
<h:link outcome="#{viewDirectory.LOGIN}">Login</h:link>

However, code completion for LOGIN after #{viewDirectory. only works when I remove the "static" keyword from the generated getter. As the static getter works fine when the BeanInfo class is present, code completion should check the BeanInfo class for properties with getters like described above.
Comment 1 Martin Balin 2016-07-07 08:52:44 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss