3

特定の方法でいくつかのボタンと選択ボックスをレンダリングするカスタム JSF コンポーネントがあります。これは、 を拡張するクラスによって行われますUIInput。このカスタム コンポーネントは、xhtmlテンプレートで次のように使用されます。

<xx:fooComponent
    value="#{fooBean.someProperty}" 
    valueChangeListener="#{fooBean.someMethodInBean}"
    someOtherProperties="true" />

JSF 2.0 を実行する JBoss 4.2.2 から、組み込みの JSF ライブラリを使用して実行する JBoss 7.1.1 に変更したためsomeMethodInBean、プロパティではないというエラーが表示されます。もちろん、これはプロパティではなく、メソッドです。世界で誰がプロパティをにバインドしますvalueChangeListenerか?

最初は、これは参照される Bean のスーパークラスにあるメソッドと関係があると思っていましたが、そうではありませんでした。この特定のメソッドを追加しFooBeanても、違いはありませんでした。

だから私の質問は、これが今壊れるように彼らは何を変更したのですか、どうすれば移行しやすい方法で修正できますか?

編集

コンポーネントは、次のように宣言されています*.taglib.xml

<!DOCTYPE facelet-taglib PUBLIC
  "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
  "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">

<!-- ... -->
<tag>
    <tag-name>fooComponent</tag-name>       
    <component>
        <component-type>myProject.FooComponent</component-type>                     
    </component>        
</tag>

...これは、次の宣言につながりますfaces-config.xml:

<component>
    <component-type>myProject.FooComponent</component-type>
    <component-class>com.myproject.somemore.UIFooComponent</component-class>
</component>

...クラスにつながりUIFooComponent extends UIInputます。

編集 2

taglibxml は次のようになります。

<facelet-taglib version="2.0"
            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">

<tag>
    <tag-name>fooComponent</tag-name>       
    <component>
        <component-type>myProject.FooComponent</component-type>                     
    </component>
    <attribute>
        <name>valueChangeListener</name>
        <method-signature>void valueChanged(javax.faces.event.ValueChangeEvent)</method-signature>  
    </attribute>        
</tag>
</facelet-taglib>

fooBeanそれでも、彼は財産を持っていないことに不平を言っていますsomeMethodInBean

編集 3

スタック トレースは次のとおりです。

Caused by: javax.el.ELException: /abc/abc.xhtml: The class 'com.myproject.managedbeans.foo.FooBean' does not have the property 'someMethodInBean'.
    at com.sun.faces.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:94)
    at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)
    at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
    at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
    at org.apache.myfaces.tomahawk.application.ResourceViewHandlerWrapper.renderView(ResourceViewHandlerWrapper.java:93)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    ... 21 more
4

1 に答える 1

4

これは、次のように、タグ属性がファイル内<method-signature>のコンポーネントの<tag>宣言でとして宣言されていないことを示しています。.taglib.xml

<attribute>
    <name>valueChangeListener</name>
    <method-signature>void valueChange(javax.faces.event.ValueChangeEvent)</method-signature>
</attribute>

これが上記のように適切に宣言されていることを確認してください。


更新.taglib.xml:ファイルが JSF 2.x Facelets XSD に準拠していることを宣言したことを確認する必要があります (したがって、従来の Facelets 1.x のような DTD ではありません)。

<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"
>

    <!-- Tags here -->

</facelet-taglib>
于 2012-06-15T12:49:22.410 に答える