我有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