2

のカスタム コンポーネントを作成し、SelectOneRadioに登録しましたがxyz.taglib.xml、これまでのところ動作しています。唯一の問題は、NetBeans がタグ属性をオートコンプリートで認識できないことです。たとえばlayout="pageDirection"、カスタム コンポーネントを持っている場合、正しくレンダリングされますが、(Ctrl + スペース) を使用するとlayoutvalue... 属性が表示されません。カスタムコンポーネントをに登録する方法は次のとおりですWEB-INF/faces-config.xml

<component>
    <component-type>com.xyz.om.ui.component.SelectOneRadio</component-type>
    <component-class>
        com.xyz.om.ui.component.SelectOneRadio
    </component-class>
    <component-extension>
        <component-family>com.xyz.om.ui.component.SelectOneRadio</component-family>
        <renderer-type>com.xyz.om.ui.renderer.SelectOneRadioRenderer</renderer-type>
    </component-extension>
</component>
<render-kit>
    <renderer>
        <component-family>com.xyz.om.ui.component.SelectOneRadio</component-family>
        <renderer-type>com.xyz.om.ui.renderer.SelectOneRadioRenderer</renderer-type>
        <renderer-class>
            com.xyz.om.ui.renderer.SelectOneRadioRenderer
        </renderer-class>    
    </renderer>
</render-kit>

私のWEB-INF/xyz.taglib.xml中で、私は持っています

<facelet-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-facelettaglibrary_2_0.xsd"
            version="2.0">
<namespace>http://example.com/ui</namespace>
<tag>
    <tag-name>selectOneRadio</tag-name>
    <component>
        <component-type>com.xyz.om.ui.component.SelectOneRadio</component-type>
        <renderer-type>com.xyz.om.ui.renderer.SelectOneRadioRenderer</renderer-type>            
    </component>
</tag>
</facelet-taglib>

だから私は次のように登録xyz.taglib.xmlweb.xmlます

<context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/xyz.taglib.xml</param-value>
</context-param>

この手順の後、カスタム コンポーネントで Ctrl + スペース (Netbeans) を押すと、class, id, parent , rendered, rendererType, transient. だから私xyz.tldはこのようにWEB-INFの下に作成しようとします

<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.1" 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">
<tlib-version>1.0</tlib-version>
<short-name>xyz</short-name>
<uri>http://example.com/ui</uri>

<tag>       
    <name>selectOneRadio</name>
    <tag-class>com.xyz.om.ui.tag.SelectOneRadioTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
            xyz description
        </description>
        <name>name</name>
        <required>false</required>
        <deferred-value>
            <type>java.lang.String</type>
        </deferred-value>         

    </attribute>
</tag>
</taglib>

しかしname、タグを書き出すと、属性はnetbeansに表示されません。私の質問は、netbeans にカスタム コンポーネントの属性をオートコンプリートさせる方法だと思います。

4

1 に答える 1

5

属性は、ファイルに基づいてオートコンプリートされ.taglib.xmlます。要素内の個々の属性をすべて登録する必要があります<tag>

<tag>
    <tag-name>selectOneRadio</tag-name>
    <component>
        <component-type>com.xyz.om.ui.component.SelectOneRadio</component-type>
        <renderer-type>com.xyz.om.ui.renderer.SelectOneRadioRenderer</renderer-type>            
    </component>
    <attribute>
        <name>id</name>
        <required>false</required>
        <type>java.lang.String</type>
    </attribute>
    <attribute>
        <name>binding</name>
        <required>false</required>
        <type>javax.faces.component.UIComponent</type>
    </attribute>
    <attribute>
        <name>rendered</name>
        <required>false</required>
        <type>java.lang.Boolean</type>
    </attribute>
    <!-- Etc.. -->
</tag>

これ.tldは、Facelets に加えて JSP もサポートする予定がある場合にのみ必須です。JSF 2.0 自体は JSP をサポートしていないことに注意してください。JSF 1.2 フォールバック方式で実行されます。

于 2012-07-10T11:08:00.800 に答える