Content Assist for JSF2 + CDI (weld) beans + Eclipse Helios

烂漫一生 提交于 2020-01-20 04:06:56

问题


Im trying JSF2 CDI (weld) beans in eclipse helios instead of ManagedBeans, but can't do the auto completion inside the expression language for my Named beans (the #{myNamedBean.Ctrl+Space} thingy)

But OTOH with ManagedBeans, the content assist works well .. Is the content assist for CDI beans supported yet in Eclipse Helios?

Anybody got experiences in this ?


回答1:


  1. Install JBoss tools. Then by adding <nature>org.jboss.tools.jsf.jsfnature</nature> to the natures section of the .project file, the support improved in my Eclipse J2EE Helios edition. (This step is probably equal to Configure->Add JSF Capabilities in the project settings.) The context completion then works for cc.attrs.<ctrl-space> when building component compositions, but sadly still not for any @ManagedBeans.

  2. Switch from ManagedBeans to CDI: I changed all @ManagedBeans to @javax.inject.Named and the scopes to @javax.enterprise.context.*Scoped etc. I also enable CDI Support in the project settings. Then I get context completion on beans in .xhtml!

First limitation: It only works when the EL is part of an attribute value. It does not work if you just use #{EL} somewhere else on the .xhtml page.

Second limitation: If you define the name of your bean via a constant, it is not recognized for context competion: Does not work: @Named(value = MyBean.BEANNAME). You have to set the name as a String, like: @Named(value = "myBean")

Third limitation: If you use parameterised method calls (e.g. with Tomcat7 or Glassfish), this is not supported by autocomplete. The autocomplete only shows get/set/is properties of the bean.

Note: It works out of the box in Netbeans 7.




回答2:


If there is any support, it would be from JBoss Tools.




回答3:


Before you install JBossTools, please note that for EL auto complete support and managed bean mapping all you need is these 2 components from the JBoss Tool set.

1. JBoss Tools JSF
2. JBoss Tools Visual Page Editor

If you do not select these specific tools then all the 20+ tools will get installed.

Also, note that sometimes your default file *.xhtml association will not change after tool installation. You may have to manually change file association preference. File>Preference>File Associations. Select *.xhtml and set "JBoss Tools Visual Page Editor" as the default editor.



来源:https://stackoverflow.com/questions/4122189/content-assist-for-jsf2-cdi-weld-beans-eclipse-helios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!