使用复合组件的新标签的属性不会被Eclipse自动完成的shortcurt显示 [英] Properties of new tags using composite component are not displayed by Eclipse auto complete shortcurt

查看:180
本文介绍了使用复合组件的新标签的属性不会被Eclipse自动完成的shortcurt显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中使用JSF 2.0开发了复合组件。我已将XHTML标签文件放在资源文件夹中。



当我点击 ctrl + space 在键盘中,标签的属性不显示。



我发现一些提示要安装Jboss工具但是没有工作。

 <?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 =masculinodefault =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 =trueitemLabel =#{lbl ['LABEL.SIM']}/>
< f:selectItem itemValue =falseitemLabel =#{lbl ['LABEL.NAO']}/>
< / p:selectOneMenu>
< / cc:implementation>

< / html>

以上是创建的一个标签的一个例子。



谢谢

解决方案

JSF 2.x Facelets支持集成在



通常可以在新的动态Web项目中配置向导,但是当导入非Eclipse项目或创建非动态Web项目项目(例如Maven原型)时,需要手动检查/添加它。



一旦集成,JSF标签自动填充默认情况下可在 java.sun.com XML命名空间中使用。





新的默认情况下不能识别xmlns.jcp.org 命名空间(目前测试的Eclipse版本是Luna SR2)。





新的 xmlns.jcp.org 命名空间只有在您添加一个物理JSF 2.2实现来构建一个完整的Java EE容器的路径,该容器在其模块中具有JSF 2.2,通过体面的服务器插件集成,并在项目的属性中设置为定位运行时,或者具体的JSF 2.2在Tomcat和克隆(或通过将其添加为Maven依赖关系)的情况下,在 / WEB-INF / lib 中实现JAR文件。





它仍然不能识别新的XML命名空间中的复合。当返回到 java.sun.com 时,复合组件标签的代码完成已经回覆,但是这些标签上的属性的代码完成不可用。





然后我安装了



关闭后重新打开Facelet(所以JBoss内置的HTML编辑器被打开;您可以设置/配置右键单击使用的编辑器,打开),然后切换到选项卡不要使用 Visual 编辑器,这是一个灾难),我终于得到了复合组件的代码完成。





只有 xmlns.jcp.org 仍然无法使用。这是一个Eclipse特定的问题,可能已经在火星或更高版本中修复。您可以随时隐藏自定义XML命名空间后面的复合命名空间,如下所示:



/WEB-INF/my.taglib.xml

 <?xml version =1.0encoding =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>



因此,总结:




  • 在项目的属性中启用JSF项目构面,以便在复合代码上执行代码完成。

  • 在复合代码中安装JBoss Tools代码完成。

  • 在项目属性中启用JBoss Tools知识库。

  • xmlns.jcp.org 在标准标签上支持的物理JSF 2.2 impl JAR。

  • 使用 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 Java EE developers" (note the EE, 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:

  • Enable JSF project facet in project's properties for code completion on composite tags.
  • Install JBoss Tools for code completion on attribtues in composite tags.
  • Enable JBoss Tools Knowledge base in project's properties.
  • Have a physical JSF 2.2 impl JAR in buildpath for xmlns.jcp.org support on standard tags.
  • Use java.sun.com XML namespace domain or a custom taglib (or a newer Eclipse version) on composite tags.

这篇关于使用复合组件的新标签的属性不会被Eclipse自动完成的shortcurt显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆