我有一个JSF按钮的ActionListener
,如下所示,
<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
我通过访问ActionRequest.
的"javax.servlet.request"得到了HttpServlet请求