我有一个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
答案 0 :(得分:1)
我通过访问“ActionRequest的javax.servlet.request”获得了HttpServletRequest。