2017-04-18 22 views
0

우리는 JSF 2.2 프로젝트 (코드가 명확하게하기 위해 간략화되었다)과 같이 사용되는 복합 컴포넌트에 가지고 제이보스에서F : 합성 성분 AJAX 리스너 제이보스의 작동이 중단 10

<!-- the page with the composite component inside --> 
<my:component methodListener="#{myBean.myMethod}" /> 

<!-- the composite component --> 
<cc:interface> 
    <cc:attribute name="methodListener" required="true" method-signature="void listener(javax.faces.event.AjaxBehaviorEvent)" /> 
    ... 
<cc:implementation> 
    <h:commandLink> 
     <f:ajax listener="#{cc.attrs.methodListener}" /> 
     <f:attribute name="myAttribute" value="myValue" /> 
    </h:commandLink> 
// the called method 
public void myMethod(AjaxBehaviorEvent event) 
{ 
    System.out.println("> " + event); 
} 

9.0.2에서 복합 컴포넌트 내 commandLink을 클릭하면 myMethod이 호출되고 이벤트가 정의되어 다시 myAttribute 값을 찾을 수 있습니다.

정확히 동일한 코드의 myMethod이 호출되지만 이벤트 매개 변수는 항상 null입니다.

여기서 뭔가 잘못하고 있습니까?

테스트 된 해결 방법은 methodListener CC 속성을 다음 코드와 같은 bean 인스턴스로 바꿀 수 있습니다. 그래도이 작업은 프로젝트에서 많은 대체물을 필요로하므로이 솔루션을 피하고 싶습니다.

<!-- the workaround composite component --> 
<cc:interface> 
    <cc:attribute name="methodBean" required="true" type="com.example.myBean" /> 
... 
<cc:implementation> 
    <h:commandLink> 
     <f:ajax listener="#{cc.attrs.methodBean.myMethod}" /> 
     <f:attribute name="myAttribute" value="myValue" /> 
    </h:commandLink> 

답변

0

글쎄, 나는 다른 관련 질문에 BalusC에서 this answer을 보지 못했습니다. 내 코드는 WF9에 근무하고 WF10에 고장 난 아직도 왜 이해하지 않는다, 그러나 여기에서 우리는 구성 요소 자체하지만 아무것도 변경하지 않아도 간단한 솔루션입니다 :

<!-- the CC xhtml --> 
<h:commandLink> 
    <f:ajax listener="#{cc.methodListener}" /> 
    <f:attribute name="myAttribute" value="myValue" /> 
</h:commandLink> 
// the CC implementation 
public void methodListener(AjaxBehaviorEvent event) 
{ 
    FacesContext context = getCurrentInstance(); 
    MethodExpression ajaxEventListener = (MethodExpression) getAttributes().get("methodListener"); 
    ajaxEventListener.invoke(context.getELContext(), new Object[] { event }); 
}