how to show popup when session is timeout and the user is inactive in jsf? - jsf

I want the application show a popup to inform inactive user when he back to use the application that the session is timeout and to click on ok to redirect him to login again.
the first problem i cant detect that the session is timeout .
the second problem evenif i detect that the session is timeout how can i show the popup ?
i tryed o detect the session timeout with a listener but didnt work
<f:event listener="#{logincontroller.checksessiontimeout}" type="preValidate"/>
i am using primefaces and glassfish.

The problem with the approach you have chosen is the session has timed out, but you already figured it out. )
The solution could be to use ExceptionHandler.
If you really want to show a popup you can redirect to the same page passing some predefined parameter based on which your popup would be rendered. As an alternative you may consider redirection to login page right away and show notification about session expiration there. The second way looks more natural to me, but this is my personal point of view.
You may find information on how to do this in BalusC blog post
also you may find some discussion on stackoverflow here with references to other similar questions. Those would still point you to the blog post I mentioned earlier

Related

customize the session message of liferay

I work with liferay 5.2 ,
Liferay display in case of inactivity this message
warning,due to inactivity,your session has espired.please save any data you may have entered before refreshing
I want to customize this message , I want to display this message:
Due to lack of use of the system will be closed
instead of default message,
and also I want to display this message in the middle of the page instead of top of the page.
so I think that I should modify the css of the div of this message in liferay
You need create hook of Language.properties file and change the default value for below key
warning-your-session-has-expired=Warning! Due to inactivity, your session has expired. Please save any data you may have entered before refreshing the page.
so you can put like this
warning-your-session-has-expired=Due to lack of use of the system will be closed.
Thanks
If you read the below link i think you will find your an answer:
Liferay User Feedback - Success and Error Messages in Portlets
This Can help you changing session out message in theme

Serverside Xpages application update causes my browser page partial refresh actions stop working - how to detect it?

Any Xpages application update in design causes the application refresh which removes scope variables, session etc. When this occures and there is a page opened in users browser with some partial refresh action buttons ... such buttons simply do nothing when clicked which is quite confusing. No message that's warning the user that the page is stale or something. Is there a way how to detect such situation in general so I can inform user in browser with some dialog that he should reload the entire page?
For all scope variables above request (which gets initialized when you send a request and is always shiny and new) you never can take their existence for granted. Best example: user leaves a form open, locks the PC, goes for lunch, lets the session expire (which also deletes the view scope). (S)he comes back, opens a new tab and logs in - so there is a valid (new) session, hits submit in the first tab -> bum all your code fails.
This is the same scenario as an updated design short of the scenario Panu was pointing to.
So in your code check for the existence of your scoped variables and force a full refresh. Or (I like that better) add an error to the page so that gets displayed with an appropriate action.

Is there actually a way to open a popup on browser CLOSE?

I'm trying to launch a "logout" page if the usesr closes the browser...I've looked for a couple of days and I think I have looked at all of the related topics...tried quite a few...but so far, nothing is working the way I need it to...
Everything seems to trigger just navigating to the next page...I want to be able to navigate the site and NOTHING IF I LOG OUT...but if I CLOSE THE BROWSER (or the DOMAIN changes), I want to fire the logout page.
Actually, it really doesn't need to open a popup...but that would be my preference...
Thanks for any help in getting a definitive answer...
HOLD THE PHONE...
Just FYI...I found what seems to be working here:
[http://eureka.ykyuen.info/2011/02/22/jquery-javascript-capture-the-browser-or-tab-closed-event/][1]
...and it also seems that there are some very useful variations from contributers.
I also added a line to the original script to execute my logout page...
You should be able to add a listener using onbeforeunload and ask the user if they want to log out in the prompt https://developer.mozilla.org/en-US/docs/DOM/window.onbeforeunload

How to avoid BusyConversationException in jsf

I'm getting BusyConversationException while navigating through pages in my jsf project. This mostly happens if the user tries to navigate to another page during an ajax call. This also happens when the user clicks on a link right after clicking on another link without waiting for loading of the page.
For example if the user clicks on more than one link which are generated through a code similar to below one we definitely get this exception. Another example is, lets say the user enter a query on a text field, and our application make an ajax call for searching this query. During that query if the user click on some button to navigate to another page BusyConversationException occurs too.
<h:commandLink value="#{theProfile.profileName}"
title="#{theProfile.profileName}"
action="#{profileBean.aProfileSelected}">
<f:setPropertyActionListener target="#{currentProfileWebBean.theProfile}" value="#{theProfile}"/>
</h:commandLink>
I can catch this type of exception in an ExceptionHandler class which extends ExceptionHandlerWrapper class but I can't save my current state and the best I can do for this case is to redirect to main page when this exception occurs.
Is there any solution for avoiding this? Thanks in advance for answers and comments.
As mentioned in the other answers, this happens if an ajax request is still being processed or if an ajax event is triggered prior to the actual click on the submitting commandLink or commandButton (for instance by a change event on an input field).
Therfore it is not possible to avoid BusyConversationExceptions with onclick="preventEventPropagation(event)";, since the AJAX events are not triggered via propagation.
The issue can easily be avoided by listening for running ajax requests and blocking submits until the pending ajax events have been completed.
The issue and solution are explained in more detail in this blog post JSF2 AJAX/Submit conversation issue.
i found this,
Indicates that the container has rejected a request because a concurrent request is associated with the same conversation context.
The container ensures that a long-running conversation may be associated with at most one request at a time, by blocking or rejecting concurrent requests. If the container rejects a request, it must associate the request with a new transient conversation and throw an exception of type BusyConversationException from the restore view phase of the JSF lifecycle.
refer here
I've been seeing this occasionally too. I'm starting to think it's a good idea to put some effort into serializing access to conversations:
Avoid propagating the conversation ID (cid) when you don't need that conversation instance for the target view. Specifically, unrelated navigation links/buttons should suppress the cid parameter (haven't thought about exactly how to do that)
When starting a request that uses an active conversation, disable other UI elements that propagate the conversation and could therefore cause concurrent access. The PrimeFaces or (even better) PrimeFaces Extensions blockUI components work well as a translucent overlay, along with a PrimeFaces p:ajaxStatus to show the busy status.
Begin conversations as late as possible. This will minimize the cases where a long-running conversation would be propagated.
I don't think that any of this is a complete solution, though. As soon as the cid ends up in the location bar (which happens when you do a non-ajax post back of a form when a conversation is active), you potentially lose control over the timing of access to that conversation due to multiple tabs/windows, bookmarks, etc.
I also faced the same problem, when I used to click the .
I have read in one of the book, busyConevrsation happens with that event two actions are happening, so they said use : onclick="preventEventPropagation(event)"; in commandLink to prevent the event propagation for that click. So I have used the same and it's working for me.
So now am not getting the BusyConversationException :)

Unable to get my custom JSF Login Portlet working

I am using webSphere portal 6.1. I wrote my own custom login portlet and placed in the Login page from the portal server. The page loads fine the problem is when I try to login. It takes 2 attempts to login. The first time when I try to login, the page refreshes (I don’t see any exception on the consol). If I enter the user id/password for the second time, the login works perfectly
After extensive debugging this is what I found,
The first time when I try to login, the process action get called but it skips the managed bean and call the doView. The second time, the process action get called and the managed bean get called (login is successful) and then the doView get called. So I decided to take a look at the html output, sure enough the action url is different. The url for initil load is
action="/wps/portal/esb/!ut/p/c5/04_SB8K8xLLM9MSSzPy8xBz9CP0os3h355AAV0dnEwMLPycTA8_AUINQL1cLAwNXU_1wkA6zeAMcwNFA388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50qHnihCJTZIFgURycbf8IiG5wSsvS4MYITZHUqYzDcNVC7cxvIen-_msergaAj6XtBo9GuWwADk8xSfb5jCslG0O8uem8wILCTobn3VGKkMHQ3xR9Xw5y9MoGHeKEaG0I5_JB2kmOW2eWTiJY4i9o6bLxzPwM5nwGSAif8fqCuffi36iX0Pu1OgcsF_95QIhOKKYUv9prKxO_6xbf3WmOSaJCDLfrRpPaK3CYnHFkt8oxodC8uG2fvJ2F4aLYyMd6vrb1IbL2fgESn2LPEf4ZSkH6PeaKONvL9mm5Prguu8ZvwMPzk7z6b1_OLI5iox6ivHBoZb32Y0far1f7atWl0jpaUYilQd9xIClj36LL3oTjZNbLmTiKaQcH8dcea7YFayk8bk3S2dC_8cn9afvJQ6ZAzOd-_cInXqhfj7eWb5Jj4nbXKK4k9mmJw6358T99Yvx1Rqpf6fj_FnJiKsQlPn7g7x1tjrwMTxvI3GbTALcHCI3fl-zw2rT_bYvONm7glRu93peJk7zG3sdtGzhb--RcqYJzK/dl3/d3/L0lDU0lKSkthWWtLQ2xFWm1ZQSEhL29Pb2dBRUlRaGpCS0VRQUFBRVpDZ0dRNEtRcGNFb2lBWUFEUkVBd0FCaUlCZ0FMRVFEQUFBQSEhLzRDMWI5V19OcnhRREVTWklKUkNBLzdfR0NUUEVBQzQwOEdQRDBJUTFGUVQ2MzMwRzUvMTQ3Nzg3OTY4NTYzL2phdmF4LnNlcnZsZXQuaW5jbHVkZS5wYXRoX2luZm8vJTBqc3BzJTBFU0JMb2dpblBvcnRsZXRWaWV3LmpzcA!!/"
Can some please explain me what going on here?
Thanks
i think i found a solution for my problem. it seems that JSF is trying to save it's viewstate in the session, but public session is not enabled by default for anonymous user. So changing the state saving method in web.xml from server to client seem to do the trick

Resources