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

我通过访问“javax.servlet.request of ActionRequest.

于 2013-01-01T14:12:13.523 回答