PrimeFaces is now PrimeFace$, and isn’t open source anymore.
Their license page still reads:
PrimeFaces is open source, completely free to use and licensed under Apache License V2. Briefly you can use PrimeFaces in open source or commercial projects following the terms of the license.
Apache License
Version 2.0, January 2004
That’s not the case anymore, since private branches exist now that are only available to paying clients.
PrimeTek will now make sure that, from now on, only bug rigged, released once in a blue moon pre-alpha versions will be made available to the community, who will serve as a bunch of free beta testers.
ViewExpiredException usually occurs whena postback is triggered after the Session has expired. Here are a couple of ways to handle it:
Method #1: just use web.xml
<error-page> <exception-type>javax.faces.application.ViewExpiredException</exception-type> <location>/ViewExpiredException.xhtml</location> </error-page>
Method #2: use JSF’s ExceptionHandler mechanism
Create an ExceptionHandlerFactory
package foo; import javax.faces.context.ExceptionHandler; import javax.faces.context.ExceptionHandlerFactory; public class MyExceptionHandlerFactory extends ExceptionHandlerFactory { private ExceptionHandlerFactory parent; // This injection is handled by JSF public MyExceptionHandlerFactory(ExceptionHandlerFactory parent) { this.parent = parent; } @Override public ExceptionHandler getExceptionHandler() { return new MyExceptionHandler(parent.getExceptionHandler()); } }
Implement your ExceptionHandler by extending ExceptionHandlerWrapper and overriding the handle() method
package foo; import java.util.Iterator; import java.util.logging.Logger; import javax.faces.application.FacesMessage; import javax.faces.application.ViewExpiredException; import javax.faces.context.ExceptionHandler; import javax.faces.context.ExceptionHandlerWrapper; import javax.faces.context.FacesContext; import javax.faces.event.ExceptionQueuedEvent; public class MyExceptionHandler extends ExceptionHandlerWrapper { private ExceptionHandler wrapped; Logger log; FacesContext fc; public MyExceptionHandler(ExceptionHandler exceptionHandler) { wrapped = exceptionHandler; log = Logger.getLogger(this.getClass().getName()); fc = FacesContext.getCurrentInstance(); } @Override public ExceptionHandler getWrapped() { return wrapped; } @Override public void handle() { Iterator<ExceptionQueuedEvent> i = super.getUnhandledExceptionQueuedEvents().iterator(); while (i.hasNext()) { Throwable t = i.next().getContext().getException(); if (t instanceof ViewExpiredException) { try { // Handle the exception, for example: log.severe("ViewExpiredException occurred!"); fc.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "An exception occurred", "ViewExpiredException happened!")); fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "ViewExpiredException"); } finally { i.remove(); } } /* else if (t instanceof SomeOtherException) { // handle SomeOtherException } */ } // let the parent handle the rest getWrapped().handle(); } }
Register your ExceptionHandlerFactory in faces-config.xml
<factory> <exception-handler-factory>foo.MyExceptionHandlerFactory</exception-handler-factory> </factory>