Ok simple question. I have a JSF application, containing a login page. The problem is if the user loads the login page, leaves it for a while, then tries to login the session expires and a ViewExpiredException is thrown. I could redirect back to the login when this happens, but that isn't very smooth. How can I allow this flow to properly login without an additional attempt?
相关问题
- java.lang.NullPointerException at java.io.PrintWri
- h:selectOneMenu in p:dataTable doesn't submit
- PrimeFaces block UI does not work when the compone
- primefaces orderlist not getting updated with the
- JSF2 composite cc.attrs expression does not evalua
相关文章
- How to allow numbers only using f:validateRegex
- JSF 2.0: ajax request when press ENTER
- Formatting a double in JSF
- React - How to check if JWT is valid before sendin
- django 1.9 and registration/login.html
- How to get the user login/logoff time by Python fo
- PHP Session Class and Use / Secure Logged In Page
- Swipe a splash screen to get to a login screen (An
With jsp you can disable the session for a page including this directive
<%@ page session="false" %>
. There must be something similar for jsf.Couple of slightly hacky solutions:
<meta http-equiv="refresh" content="5"/>
tag to automatically reload the page every so often.We use IceFaces at work which automatically detects when your session has expired and displays a pop-up alerting you to the fact. But we do still sometimes have problems on the login page for some reason.
Update
As of Mojarra 2.1.19 / 2.2.0 you can now set the transient attribute of the
<f:view>
to true:You can read about in on Balusc's blog here:
http://balusc.blogspot.com.br/2013/02/stateless-jsf.html
Original
If you're using Facelets you can create your own ViewHandler to handle this:
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 build the view for you.
Set this in your face-config.xml as follows:
If you're using JSF without Facelets (i.e. JSPs) you can try having the class extend ViewHandlerWrapper - note that buildView() will not be available. Hopefully createView() on it's own will set the view up correctly but I'm not 100% sure with JSF/JSP.
It sounds like your login page is in session scope, when it really doesn't need to be. Request scope should be fine for a login page (since, realistically there shouldn't be anything in session before the user logs in). Once the user logs in, you may have this issue crop back up, but Phill's ideas are very good from there on.