0
votes

This is my flow (simplified):

<view-state id="create" view="createCustomer.xhtml">
    <transition on="create" to="end">
        <evaluate expression="controller.validateCustomerFilled(customer)"/>
    </transition>
</view-state>

<end-state id="end" view="customerCreated.xhtml">
    <on-entry>
        <evaluate expression="controller.createCustomer(customer)"/>
    </on-entry>
</end-state>

and my Facelet (also simplified):

<p:commandButton value="Test Ajax" action="create" update="content, messages"/>
<p:commandButton value="Test No Ajax" action="create" ajax="false"/>

As long as "customerCreated.xhtml" doesn't contain a h:form, everything seems to work fine. But if it does exist, the following exception gets thrown:

java.lang.IllegalStateException: The current state 'end' of this flow 'customer/create' is not a view state - view scope not accessible
at org.springframework.webflow.engine.impl.FlowSessionImpl.getViewScope(FlowSessionImpl.java:119)
at org.springframework.webflow.engine.impl.RequestControlContextImpl.getViewScope(RequestControlContextImpl.java:130)
at org.springframework.faces.webflow.FlowResponseStateManager.saveState(FlowResponseStateManager.java:106)
at org.springframework.faces.webflow.FlowResponseStateManager.getViewState(FlowResponseStateManager.java:100)
at javax.faces.application.StateManager.getViewState(Unknown Source)
at javax.faces.application.StateManagerWrapper.getViewState(Unknown Source)
at com.sun.faces.context.PartialViewContextImpl.renderState(Unknown Source)
at com.sun.faces.context.PartialViewContextImpl.processPartial(Unknown Source)
at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60)
at javax.faces.context.PartialViewContextWrapper.processPartial(Unknown Source)
at javax.faces.component.UIViewRoot.encodeChildren(Unknown Source)
at javax.faces.component.UIComponent.encodeAll(Unknown Source)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(Unknown Source)
at com.sun.faces.application.view.MultiViewHandler.renderView(Unknown Source)
at javax.faces.application.ViewHandlerWrapper.renderView(Unknown Source)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(Unknown Source)
at com.sun.faces.lifecycle.Phase.doPhase(Unknown Source)
at com.sun.faces.lifecycle.LifecycleImpl.render(Unknown Source)
at org.springframework.faces.support.LifecycleWrapper.render(LifecycleWrapper.java:54)
at org.springframework.faces.webflow.JsfView.render(JsfView.java:87)
at org.springframework.webflow.action.ViewFactoryActionAdapter.doExecute(ViewFactoryActionAdapter.java:40)
at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188)
at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51)
at org.springframework.webflow.engine.EndState.doEnter(EndState.java:100)
at org.springframework.webflow.engine.State.enter(State.java:194)
at org.springframework.webflow.engine.Transition.execute(Transition.java:228)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.execute(FlowExecutionImpl.java:395)
at org.springframework.webflow.engine.impl.RequestControlContextImpl.execute(RequestControlContextImpl.java:214)
at org.springframework.webflow.engine.TransitionableState.handleEvent(TransitionableState.java:116)
at org.springframework.webflow.engine.Flow.handleEvent(Flow.java:547)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.handleEvent(FlowExecutionImpl.java:390)
at org.springframework.webflow.engine.impl.RequestControlContextImpl.handleEvent(RequestControlContextImpl.java:210)
at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:231)
at org.springframework.webflow.engine.ViewState.resume(ViewState.java:195)
at org.springframework.webflow.engine.Flow.resume(Flow.java:537)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:228)
at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:57)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1285)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:473)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1143)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:81)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:927)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:262)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:955)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

This doesn't happen when using a regular h:commandButton without Ajax (when using f:ajax, simply nothing happens on the client side).

Using: - Spring 4.2.0 - Spring Webflow 2.4.2 - Primefaces 5.2 - Mojarra 2.2.9

1
Why are you using Spring WebFlow instead of JSF 2.2's builtin Faces Flow? I can understand why one would use SWF if one is still using old JSF 2.0/2.1, but this isn't the case here. Or are you simply being unaware of that new JSF 2.2 Faces Flow feature? docs.oracle.com/javaee/7/tutorial/jsf-configure003.htmBalusC
and if the second button fails to and you change it to an h:commandButton and it still fails, it is not PrimeFaces related, but pure JSF/SWFKukeltje
No, when using h:commandButton, everything works and this is how we are doing it currently. Regarding FacesFlows, we can't use them because WebSphere is...special: stackoverflow.com/questions/32522858/…user3580311

1 Answers

0
votes

You a clearly performing an 'Action' with controller.createCustomer(customer)

<end-state id="end" view="customerCreated.xhtml">
    <on-entry>
        <evaluate expression="controller.createCustomer(customer)"/>
    </on-entry>
</end-state>

Therefore, this is not really an end-state. Change this to an action-state then transition to a blank/dummy end-state.