15

カスタム JSF 2.0 コンポーネントを作成したいのですが、うまくいきません。私のコンポーネントは次のように定義されています:

 @FacesComponent(value = "myCustomComponent")
 public class CommaSeperatedOutput extends UIComponentBase { ... }

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

 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <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://www.company.com/tags</namespace>
<tag>
    <tag-name>custom</tag-name>
      <component>
        <component-type>myCustomComponent</component-type>
      </component>
</tag>
</facelet-taglib>

私のfaces-configは次のようになります:

<faces-config 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-facesconfig_2_0.xsd">
<application>
    <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>

次のエラーが表示されます。

SEVERE: JSF1068: Component with componenttype myCustomComponent could not be instantiated.
javax.faces.FacesException: Expression Error: Named Object: myCustomComponent not found.

重要かどうかはわかりませんが、ここでは JSF 2.1 と一緒に Spring 3.1 を使用しています。したがって、依存関係は Spring によって管理されます。

ここで何が起こっているのか分かりますか?

4

2 に答える 2

-2

または、Spring Containerを使用するようにfaces-config.xmlファイルを構成したので、Springアノテーションを使用できます。@Component("myCustomComponent")

于 2012-05-11T14:47:57.230 に答える