Update
As in Mojarra 2.1.19 / 2.2.0, now you can set the transition attribute <f:view> to true:
<f:view transient="true"> Your regular content </f:view>
Here you can read the Balusc blog:
http://balusc.blogspot.com.br/2013/02/stateless-jsf.html
Original
If you use Facelets, you can create your own ViewHandler to handle this:
public class LoginViewHandler extends FaceletViewHandler { public LoginViewHandler( ViewHandler viewHandler ) { super( viewHandler ); } @Override public UIViewRoot restoreView( FacesContext ctx, String viewId ) { UIViewRoot viewRoot = super.restoreView( ctx, viewId ); if ( viewRoot == null && viewId.equals( "/login.xhtml" ) ) {
Change "/login.xhtml" to your login page. This checks to see if it can restore your view, and if it cannot, and the current view is your login page, it will create and create a view for you.
Install this in your face-config.xml as follows:
<application> <view-handler>my.package.LoginViewHandler</view-handler> </application>
If you use JSF without Facelets (i.e. JSP), you can try to make the class extend ViewHandlerWrapper - note that buildView () will not be available. I hope that createView () on it will set the view itself correctly, but I'm not 100% sure with JSF / JSP.
source share