I'm working with a Liferay portlet with JSF2 and Primefaces.
A lot of my Backing Beans are SessionScoped, as they are keeping info needed from multiple pages of the same portlet, and I want them to keep this info for the whole session, so I can't turn them to ViewScoped.
This way, the user has to log-out and log-in to reset the Backing Beans, and this is the supposed behavior I wanted. But I'd like to reset them when the user navigates to another portal page. So, my question is, what is the most convenient way to do this ?
Is there some Event I could catch when changing the page, and call some custom reset function on the Portlet?
Maybe some default setting on the portlet that will automatically reset the beans (no custom reset functions) ?
Any other Ideas ?
thanx!
Related
I'am changing theme by ui.setTheme("theme-name"). It works great until I change the page - then it goes back to the default one. How to make it persistent?
Every page class has #Theme annotation with default theme's name taken from Spring's application.yml.
This happens because every time a new page is loaded in the browser (i.e. not only changing from one view to another using e.g. Navigator), a new UI instance is created. That UI instance will use the default theme unless someone has explicitly run setTheme("some-theme") again.
There are a couple of different approaches to fixing this depending on how persistent you want the theme to be.
One approach is to add #PreserveOnRefresh to your UI subclass. This will make the previous UI instance reused when reloading or temporarily navigating to some other site. It will not preserve the UI and the theme setting if the user closes their browser tab and opens a new one later on.
The other approach is that you explicitly store the user's theme selection somewhere and then manually reapply that setting in e.g. UI.init or after the user has logged in. The two most obvious candidates for storing this is in a cookie or in the user database.
I am running into weird problems when using window scope in IceFaces 3.3. When I put debug statements on constructor and destroy method (using pre-destroy annotation), I am seeing that the same bean is being created and destroyed and re-created when a single user navigates between pages. I checked the access logs on the tomcat server and it shows that the user is using a compatible browser like IE8 and is not opening any new tabs other than navigating between the pages.
What is the lifecycle of a window scoped bean. What triggers a window scope bean to be destroyed?
This behavior does not happen consistently on the same browsers. It happens for some users using IE8 while not others. But most of the cases where the bean is re-created seem to be the cases where the user is behind some kind of proxy. Would the proxy be causing such a behavior? but then again the users session remains valid i.e. the session which keep tracks the name of the user etc., stays the same between pages.
How can this behavior be solved. Is window scope unreliable?
Yes, it's unreliable and perhaps doesn't serve the purpose of window scoping. You need to implement your own custom scope and not the icefaces predefined #{window}. The class org.icefaces.application.WindowScopeManager should give you some hints as to why you are seeing the behavior.
I want to know how to put an interface where there are buttons and links in the background, in disabled mode, then it is reactivated after user authentication?
That is to say, when the user authenticates, the page in the background is active .
I use JSF and PrimeFaces.
Thank you in advance for your help.
Do you want to have effect like on this demo ?
http://www.primefaces.org/showcase/ui/confirmDialog.jsf
That's called overlay, and you can create it in primefaces, or in jquery, but that demo should do the work.
You need to know that when you create such overlay someone might open firebug and just remove overlay element and operate on site content.
Make use of disabled attribute of a JSF command/input component. It accepts a boolean expression.
E.g., assuming you're using container managed authentication to login (and thus, the logged-in user is available via #{request.remoteUser} in the view):
<h:commandButton ... disabled="#{not empty request.remoteUser}">
As you're using PrimeFaces, an alternative would be to use its <p:blockUI> component. See also its showcase for a concrete example.
I have a Grails based web app which uses Spring Security to handle user logins etc. I have hit a bit of a block and am hoping the more experienced might be able to point me in the right direction for a solution.
The application has the concept of messages which can be sent from user to user to provide a instant messaging feature. There is a timed Ajax call that is present throughout the system which is used to alert the user of any new incoming messages.
My problem is that since I have implemented this, each time the ajax call is performed, of course the users session is being refreshed, therefore never timesout. So a manual 'log out' is the only way they can log out, whereas before expiry of a session would redirect them to the login page.
Does anyone know how I can still accomplish automatic logouts whilst still have the timer functioning?
I'm hoping I can set up some kind of filter with spring security, or perhaps there's an annotation I can use on the periodically called method to instruct it NOT to refresh the users session.
As always any help & comments are appreciated.
Thanks to Long for pointing me in a different direction with his comment, I believe I have now a much better, more intuitive user friendly solution.
Rather than trying to change things on the backend, I am using a little jQuery script which is very easily configured and fits in perfect with my app which already uses jQuery and the jQuery UI.
After a specific period, a jQuery dialog pops up, modally dimming the background and informs the user due to inactivity they will soon be logged out. A progress bar is displayed which reduces until it is empty at which point if the user hasn't click my 'Continue Working' button, then I change the window location to the spring security logout controller URL, taking them back to the sign in page. It works beautifully and is very easy to configure.
The instructions can be found here : http://kenbrowning.blogspot.co.uk/2010/04/are-you-still-there.html
Kudos to Ken Browning for his library.
I've got a little problem I'd like to solve.
I use Apache Myface 2 with Tomahawk and Trinidad.
Trinidad delivers its Dialog Framework to create Modal Dialogs...
My problem is that after the Dialog is closed, I want to refresh (re-render) the caller page.
As a solution I handle the ReturnListener, update the data of my bean, and send an ExternalContext.redirect to reload my page... but my ViewScoped bean is destroyed and a new one is create !
It is quite logical, but is there a way to reload a page from a Viewscoped bean without sending a redirect (that will destroy the bean...) ?
Is the only solution to use partial redering ?
To have it work I changed the scope to Session, but it's uggly in my case.
Thanks for your answers.
If you want to stick to view scope then yes only ppr can be of help, its not actually hard to set partialTrigger on the top level element which will refresh everything inside.
On the other had if you are ok to go with session or application scope i think you already are able to do that.