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.
NetBeans 6.8: In a .xhtml file (facelets), the autocomplete assist feature (Ctrl-Space) is not listing the names of CDI (Weld) beans defined in the application. If I create a bean with @Named annotation, it doesn't show up in the list when I press Ctrl-Space inside an EL expression: "#{}" in xhtml file. If I use @ManagedBean annotation instead, the bean name appears in the list and I can search its methods, but not with @Named annotation. As an example, to reproduce the behavior, just create a Web project on NetBeans 6.8, using JSF2 and facelets, named testApp. Then, create a new java class, say 'TestClass' in 'my' package: package my; import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.inject.Named; @Named @SessionScoped public class TestClass implements Serializable { private static final long serialVersionUID = 1L; private String str; public String getStr() { return str; } public void setStr(String str) { this.str = str; } public String clicked() { System.out.println("Button clicked"); return null; } } Decorate the class with @Named and @SessionScoped annotations, create a private String field named 'str', getter and setter, and a public method named 'clicked', for the button click action. The CDI bean is ready to go. I'm not defining a name for the bean so a standard one is used, that is the name of the class with the first letter in lower case, in this case, 'testClass'. Now put some code in 'index.xhtml' to interact with the bean. <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>Facelet Title</title> </h:head> <h:body> <h:form> field: <h:inputText value="#{testClass.str}"/> <h:commandButton value="Click me!" action="#{testClass.clicked}"/> </h:form> </h:body> </html> Finally, create an empty file in the WEB-INF folder named 'beans.xml' to trigger the CDI service. The app works as expected. The problem is, when I type <h:inputText value="#{}"/> in index.xhtml, NetBeans shows a list of components that can be used for this EL expression, but no CDI bean is included on the list.
The JSR-299 Context and Dependency Injection (CDI) is part of Java EE 6 Specification so its features should be integrated into netbeans autocomplete and code assist system.
This is actually pretty important because there is a strong sentiment by some in the JSF expert group that @Named should be preferred to @ManagedBean in most cases. It would be a shame if people got lured into @ManagedBean just because of the IDE support.
This is serious deficiency which needs to be amended ASAP.
For now I'm assigning it to you Denis.
I have added API methods into Web Beans model which allow to get Java Elements with @Named annotation. Also there is a method which returns "named" value . So I reassign this issue into JSF area.
It would also need to resolve elements (methods or fields) which are annotated with @Produces as these can also be used within EL expressions.
(In reply to comment #6) > It would also need to resolve elements (methods or fields) which are annotated > with @Produces as these can also be used within EL expressions. Ignore this, the @Named annotation would be required in addition to @Produces in this case.
should be fixed in web-main#826629b831a0 As for the CDI support module, there used to be no public packages exposed, so supposing this wasn't intentional, I exposed the api package as fried to the web.jsf.editor module. I know wery little of what are the plans for this module regarding the api level, so whoever is involved, please review and possibly take appropriate actions. By the way, I must do emphasize that the EL support code is a mess and needs to be redone from scratch. The fix is made with respect to this fact.
Integrated into 'main-golden', will be available in build *201001150201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/826629b831a0 User: Marek Fukala <mfukala@netbeans.org> Log: #178687 - CDI beans names not listed in autocomplete window
Additional important fix which needs to be put into the patch as well! web-main#56083e99ed95 - proper handling of web beans names.
verified. 100118-a10216e72f6c (web-main)
Integrated into 'main-golden', will be available in build *201001190201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/56083e99ed95 User: Marek Fukala <mfukala@netbeans.org> Log: #178687 - additional fix: proper handling of web beans names
The changeset http://hg.netbeans.org/main-golden/rev/56083e99ed95 uses the method WebBeansModel.getNamedElements(). The mentioned method has been introduced by following the changeset http://hg.netbeans.org/main-golden/rev/65946d78b9f8 however a "simple" port doesn't work because a new implementaion of WebBeansModelProvider is needed. Could you please provide a changeset for the method WebBeansModel.getNamedElements() and its implementation applicable in the release68_fixes branch?
The fix has been ported into the release68_fixes repository. http://hg.netbeans.org/release68_fixes/rev/2813fdcf740e The fix has been ported together with the bugfix of issue #179629. If a rollback is needed, both issues have to be skipped together. Since the port is non-trivial (please see the changeset), please consider wider and deeper testing.
verified in 68_fixes build NetBeans IDE 6.8 (Build 201001261800)
Thanks for this enhancement. Netbeans is, without any dounbt, the best IDE around, and it gets even better with this theese quick responses to the community requests. Geraldo.
Thanks for the words of support Geraldo! It is always good to get a feedback and even better if it is positive one. :-) FYI: http://wiki.netbeans.org/NewAndNoteworthy69m1#Context_and_Dependency_Injection lists new CDI features.