我在 Eclipse 中使用 JSF 2.0 开发了复合组件.我一直将我的 XHTML 标记文件放在 resources
文件夹中.
当我在键盘上点击 ctrl + space 时,标签的属性不显示.
我发现了一些提示安装Jboss 工具"但没有用的提示.
<?xml version='1.0' encoding='UTF-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 过渡//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"xmlns:cc="http://xmlns.jcp.org/jsf/composite"xmlns:h="http://xmlns.jcp.org/jsf/html"xmlns:f="http://xmlns.jcp.org/jsf/core"xmlns:p="http://primefaces.org/ui"><cc:接口><cc:属性名="值"/><cc:属性名="标签"/><cc:attribute name="masculino" default="true"/></cc:接口><cc:实现><p:selectOneMenu value="#{cc.attrs.value}" label="#{cc.attrs.label}"><f:selectItem itemValue="#{null}"itemLabel="#{cc.attrs.masculino ? lbl['LABEL.TODOS'] : lbl['LABEL.TODAS']}"/><f:selectItem itemValue="true" itemLabel="#{lbl['LABEL.SIM']}"/><f:selectItem itemValue="false" itemLabel="#{lbl['LABEL.NAO']}"/></p:selectOneMenu></cc:实现></html>
以上是创建一个标签的一个示例.
谢谢
JSF 2.x Facelets 支持集成在 "
这通常可以在新的Dynamic Web Project 向导中配置,但在导入非 Eclipse 项目或创建非Dynamic Web Project 项目(例如 Maven 原型)时,那么你需要手动检查/添加它.
集成后,JSF 标记自动完成功能默认在 java.sun.com
XML 命名空间中可用.
默认不识别新的 xmlns.jcp.org
命名空间(当前测试的 Eclipse 版本是 Luna SR2).
新的 xmlns.jcp.org
命名空间只有在你添加了一个物理 JSF 2.2 实现来构建路径时才能工作,以在其模块中包含 JSF 2.2 的完整 Java EE 容器的风格,通过一个不错的服务器插件集成并在项目属性中设置为 Targeted Runtimes,或者在 Tomcat 和克隆的情况下在 /WEB-INF/lib
中设置一个具体的 JSF 2.2 实现 JAR 文件(或将其添加为 Maven 依赖项).
它只是仍然无法识别新 XML 命名空间中的组合.改回 java.sun.com
时,复合组件标签的代码补全又回来了,但这些标签上的属性的代码补全不可用.
然后我安装了
关闭并重新打开 Facelet 后(这样 JBoss 内置 HTML 编辑器就会打开;您可以设置/配置右键单击使用的编辑器,打开方式),然后切换到 Source 选项卡(请不要使用Visual 编辑器,这是一场灾难),我终于得到了复合组件属性的代码完成.
只有 xmlns.jcp.org
仍然不起作用.这是一个 Eclipse 特定问题,可能已经在 Mars 或更新版本中修复.您始终可以将复合命名空间隐藏在自定义 XML 命名空间后面,如下所示:
/WEB-INF/my.taglib.xml
/WEB-INF/web.xml
<param-name>javax.faces.FACELETS_LIBRARIES</param-name><参数值>/WEB-INF/my.taglib.xml</参数值></上下文参数>
所以,总结一下:
xmlns.jcp.org
支持.java.sun.com
XML 命名空间域或自定义 taglib(或更新的 Eclipse 版本).I have developed composite components using JSF 2.0 in Eclipse. I've been putting my XHTML tag files inside resources
folder.
When I hit ctrl + space in keyboard, the property of the tag are not displayed.
I found some tips told to install "Jboss tools" but didn't work.
<?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:cc="http://xmlns.jcp.org/jsf/composite"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<cc:interface>
<cc:attribute name="value"/>
<cc:attribute name="label"/>
<cc:attribute name="masculino" default="true"/>
</cc:interface>
<cc:implementation>
<p:selectOneMenu value="#{cc.attrs.value}" label="#{cc.attrs.label}">
<f:selectItem itemValue="#{null}"
itemLabel="#{cc.attrs.masculino ? lbl['LABEL.TODOS'] : lbl['LABEL.TODAS']}" />
<f:selectItem itemValue="true" itemLabel="#{lbl['LABEL.SIM']}" />
<f:selectItem itemValue="false" itemLabel="#{lbl['LABEL.NAO']}" />
</p:selectOneMenu>
</cc:implementation>
</html>
Above is one example of one tag created.
Thanks
JSF 2.x Facelets support is integrated in "Eclipse IDE for Enterprise Java Developers" (note the Enterprise, thus not "Eclipse IDE for Java Developers"), since Eclipse Helios (version 3.6, released June 2010). You need to ensure that the JavaServer Faces facet is enabled in Project Facets section of project's properties and is set to a minimum of version 2.0.
This is usually configureable during in new Dynamic Web Project wizard, but when importing non-Eclipse projects or creating non-Dynamic Web Project projects (e.g. Maven archetypes), then you need to manually check/add it.
Once integrated, JSF tag autocomplete is by default available on java.sun.com
XML namespace.
The new xmlns.jcp.org
namespace isn't recognized by default (currently tested Eclipse version is Luna SR2).
The new xmlns.jcp.org
namespace will only work if you've added a physical JSF 2.2 implementation to build path in flavor of a full fledged Java EE container having JSF 2.2 in its modules, integrated via a decent server plugin and set as Targeted Runtimes in project's properties, or a concrete JSF 2.2 implementation JAR file in /WEB-INF/lib
in case of Tomcat and clones (or by adding it as a Maven dependency).
It only still doesn't recognize composites in the new XML namespace. When changing back to java.sun.com
, code completion of composite component tags is back, but code completion of attributes on those tags is not available.
Then I installed JBoss Tools 4.2.3 for Eclipse Luna and enabled the JBoss Tools Knowledge Base in project's properties.
After closing and reopening the Facelet (so JBoss builtin HTML editor gets opened; you can set/configure the editor used by rightclick, Open With), and switching to the Source tab (please don't use Visual editor, this is a disaster), I finally got code completion of attribtues on composite components.
Only the xmlns.jcp.org
still didn't work. It's an Eclipse specific issue and probably already fixed in Mars or newer. You can always hide the composite namespace behind a custom XML namespace as below:
/WEB-INF/my.taglib.xml
<?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd"
version="2.2"
>
<namespace>http://example.com/my</namespace>
<composite-library-name>components</composite-library-name>
</facelet-taglib>
/WEB-INF/web.xml
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/my.taglib.xml</param-value>
</context-param>
So, summarized:
xmlns.jcp.org
support on standard tags.java.sun.com
XML namespace domain or a custom taglib (or a newer Eclipse version) on composite tags.这篇关于Eclipse 自动完成快捷方式不显示使用复合组件的新标签的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!