복붙노트

[SPRING] @FacesComponent가있는 JSF 사용자 정의 구성 요소가 Spring Boot에 없습니다.

SPRING

@FacesComponent가있는 JSF 사용자 정의 구성 요소가 Spring Boot에 없습니다.

사용자 정의 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에서 관리합니다.

여기 무슨 일이 일어나고 있는지 아십니까?

해결법

  1. ==============================

    1.[움직이는 저자의 해결책은 여기에있다]

    [움직이는 저자의 해결책은 여기에있다]

    봄이 나쁜 사람인 것처럼 보입니다. 컴포넌트에서 @FacesComponent (value = "myCustomComponent") 주석을 제거하고 대신 faces-config에 다음과 같이 정의했습니다.

    <component>
        <component-type>myCustomComponent</component-type>
        <component-class>com.company.jsf.component.CommaSeperatedOutput</component-class>
    </component>
    

    이제 작동합니다.

  2. ==============================

    2.또는 Spring Container를 사용하도록 faces-config.xml 파일을 구성 했으므로 Spring 어노테이션 @Component ( "myCustomComponent")를 사용할 수 있습니다.

    또는 Spring Container를 사용하도록 faces-config.xml 파일을 구성 했으므로 Spring 어노테이션 @Component ( "myCustomComponent")를 사용할 수 있습니다.

  3. from https://stackoverflow.com/questions/9684402/jsf-custom-component-with-facescomponent-is-not-found-in-spring-boot by cc-by-sa and MIT license