0

ActionListener次のようにJSFボタン用があります。

<h:commandButton id="id1" action="#{Mybean.Submit}" value="Click">
    <f:actionListener binding="#{Mybean.actionListenerImpl}" type="bean.ActionListenerImpl" />
</h:commandButton>

ActionListener次のように実装されます。

public void processAction(ActionEvent event) throws AbortProcessingException {
    FacesContext fc = FacesContext.getCurrentInstance();
    HttpServletRequest req = (HttpServletRequest)fc.getExternalContext().getRequest();
    PortletBackingContext pbc = PortletBackingContext.getPortletBackingContext(req);
    pbc.fireCustomEvent("test", "test");
}

しかし、これは次の例外をスローしています:

java.lang.ClassCastException: com.bea.portlet.container.ActionRequestImpl cannot be cast to javax.servlet.http.HttpServletRequest
    at bean.ActionListenerImpl.processAction(ActionListenerImpl.java:18)

カスタム イベントを発生させることができるオブジェクトHttpServletRequestを取得するには、にアクセスする必要があります。PortletBackingContext

weblogic 10.3.0 で JSF 1.2 を使用しています。

4

1 に答える 1

1

ActionRequest の「javax.servlet.request」にアクセスして HttpServletRequest を取得しました。

于 2013-01-01T14:12:13.523 に答える