1 18 package org.apache.beehive.netui.pageflow.faces.internal; 19 20 import org.apache.beehive.netui.pageflow.internal.InternalUtils; 21 import org.apache.struts.action.ActionForm; 22 23 import javax.faces.event.ActionListener; 24 import javax.faces.event.ActionEvent; 25 import javax.faces.event.AbortProcessingException; 26 import javax.faces.context.FacesContext; 27 import javax.faces.el.ValueBinding; 28 import javax.servlet.ServletRequest ; 29 30 36 public class PageFlowActionListener 37 implements ActionListener 38 { 39 private ActionListener _delegate; 40 41 public PageFlowActionListener( ActionListener delegate ) 42 { 43 _delegate = delegate; 44 } 45 46 public void processAction( ActionEvent event ) throws AbortProcessingException 47 { 48 Object submitFormBean = event.getComponent().getAttributes().get( "submitFormBean" ); 49 FacesContext context = FacesContext.getCurrentInstance(); 50 51 if ( submitFormBean != null ) 52 { 53 ValueBinding binding = context.getApplication().createValueBinding( "#{" + submitFormBean + '}' ); 54 Object beanInstance = binding.getValue( context ); 55 Object request = context.getExternalContext().getRequest(); 56 assert request instanceof ServletRequest : request.getClass().getName(); 57 ActionForm wrappedFormBean = InternalUtils.wrapFormBean( beanInstance ); 58 InternalUtils.setForwardedFormBean( ( ServletRequest ) request, wrappedFormBean ); 59 } 60 61 _delegate.processAction( event ); 62 63 Object request = context.getExternalContext().getRequest(); 64 assert request instanceof ServletRequest : request.getClass().getName(); 65 ServletRequest servletRequest = ( ServletRequest ) request; 66 67 String actionURI = ( String ) servletRequest.getAttribute( PageFlowNavigationHandler.ALREADY_FORWARDED_ATTR ); 68 69 if ( actionURI != null ) 70 { 71 throw new AbortProcessingException( "PageFlowNavigationHandler forwarded to: " + actionURI ); 72 } 73 } 74 } 75 | Popular Tags |