문제

내가 찾는 것은 솔루션을 대체 @ManagedBean(eager=true) 주석에서 JSF2.2.

나는 좋은 노트의 제안 과 같이 할 수 있도록 코드 실행 중에서 응용 프로그램 시작합니다.

요 그러나 액세스 FacesContext, 므로,이 솔루션을 작동하지 않습니다. FacesContext.getCurrentInstance() 은 여전히 null 이 시간입니다.

나의 대안을 찾기 위해 AfterDeploymentValidation 에서 SPI,아무것도 발견하지 못했다.

으로 개발자와의 DeltaSpike 하지 않는 것 계획을 구현하는 대체 @ManagedBean(eager=true) 로 OmiFaces 지원하지 않는 이러한 종류의 솔루션, .나는 메시지를 보내에서 병합니다.

간,그냥 액세스 @ManagedScoped(eager=true) 콩로 변환 @Named, 에서,내 웹 애플리케이션반 xhtml 헤더,하지만 그것은 종류의 ugly.

도움이 되었습니까?

해결책

을위한 최고의 솔루션 JSF 응용 프로그램 DeltaSpike 은 다음과 같다:

@ApplicationScoped
public class MyBean
{
    public void init(@Observes PostConstructApplicationEvent event)
    {
        // init here
    }
}

다른 팁

OmniFaces 1.8 가 CDI 호환성 @Eager 뿐만 아니라에서 작동 @Named @ApplicationScoped, 지만,als 에 CDI 의 @SessionScoped@RequestScoped 고 OmniFaces @ViewScoped.도 블로그 항목에선보일 예제.

당신은 그것을 사용할 수 있는 중 @Eager @ApplicationScoped:

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
import org.omnifaces.cdi.Eager;

@Named
@Eager
@ApplicationScoped
public class Bean {
    // ...
}

@Startup, 는 스테레오타입에 대한 @Eager @ApplicationScoped:

import javax.inject.Named;
import org.omnifaces.cdi.Startup;

@Named
@Startup
public class Bean {
    // ...
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top