2012-10-30 79 views
1

我希望eclipse(juno或更早版本)爲我的自定義taglib提出完成建議。自定義jsf taglib自動完成

所以,我寫了一個.taglib.xml文件,其代碼爲:

<?xml version="1.0" encoding="UTF-8"?> 
<facelet-taglib id="sc" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd" 
    version="2.0" 
> 
    <namespace>http://www.senat.fr/taglib/sencommons</namespace> 

    <tag> 
     <description> 
      <![CDATA[ 
            blah blah blah 
      ]]> 
     </description> 
     <tag-name>senDateYearBegEnd</tag-name> 
     <component> 
      <component-type>fr.senat.faces.validators.SenDateYearBegEnd</component-type> 
     </component> 
     <attribute> 
      <description> 
       <![CDATA[ 
        Identifiant unique. 
       ]]> 
      </description> 
      <name>id</name> 
      <required>false</required> 
      <type>java.lang.String</type> 
     </attribute> 
    [...] 
    </tag> 
</facelet-taglib> 

這.taglib.xml文件在META-INF目錄

的例子標籤家常omn​​ifaces版本的ValidateMultiple。

但是,與omnifaces相反(只是一個例子),當我在xhtml文件中使用包含此taglib定義的依賴關係使用此lib時,我在eclipse中沒有完成。

例子:

<html lang="fr" 
     xmlns="http://www.w3.org/1999/xhtml" 
     xmlns:h="http://java.sun.com/jsf/html" 
     xmlns:f="http://java.sun.com/jsf/core" 
     xmlns:ui="http://java.sun.com/jsf/facelets" 
     xmlns:composite="http://java.sun.com/jsf/composite" 
     xmlns:p="http://primefaces.org/ui" 
     xmlns:sen="http://java.sun.com/jsf/composite/sen" 
     xmlns:fn="http://java.sun.com/jsp/jstl/functions" 
     xmlns:sf="http://www.senat.fr/taglib/senfunctions" 
     xmlns:sc="http://www.senat.fr/taglib/sencommons" 
     xmlns:o="http://omnifaces.org/ui" 
     xmlns:of="http://omnifaces.org/functions"> 

如果鍵入

<o: 

然後按CTRL +空間,我得到了提案標籤,然後在屬性。

如果鍵入

<sc: 

然後按CTRL +空間,我什麼也沒得到。

我的lib中被定義爲我的項目的依賴的方式一樣omnifaces ...

我什麼也沒看見在omnifaces pom.xml speecial。我該怎麼辦?

+0

是您的自定義標籤庫真的被Maven引用了嗎?這不是真的被Eclipse項目的*部署程序集*所引用嗎?這將解釋找不到taglib文件。 – BalusC

+0

如何檢查1)它是否被maven引用2)它是否被eclipse部署程序集引用?謝謝。 –

+0

Maven:不知道(我不用它來開發,所以不能從經驗中得知)。 Eclipse:檢查項目屬性中的*部署程序集*部分。 – BalusC

回答

2

以下適用於Eclipse 2.7.2/Indigo至少。

檢查特立尼達執行顯示,它也需要一個.tld文件具有相等內容(不是1:1相同的內容請參見下面的.tld格式)在同一WEB-INF文件夾作爲.taglib.xml

命名的.tld的 - >mytaglib.taglib.xml - >mytaglib.tld

TLD內容應該是這樣的 - 例如,僅供參考 - 你必須填寫的一切:

<taglib xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd" version="2.1"> 

     <display-name>'free text'</display-name>  
     <tlib-version>1.0.0</tlib-version> 
     <short-name>'match with name preceding .taglib.xml'</short-name> 
     <uri>'your url'</uri> 

     <tag> 
      <description> 
      </description> 

      <name>'tag name'</name> 
      <body-content></body-content> 
      <attribute> 
      <description></description> 
      <name></name> 
      <required></required> 
      <deferred-value/> 
      </attribute> 
     </tag> 
    </taglib> 
+0

'.tld'文件僅用於JSP頁面,對於Facelets頁面不應該是必需的,除非使用了非常差/差的IDE插件。 – BalusC