I'm writing an application in JSF 1.2 that has a session in a backing bean.
The biggest stability issue happens when the user refreshes the page (by pressing F5) or uses the backward arrow in the browser to go back.
I would like some 'smart' (knowledgeable) way to overcome this.
The most common exception I get is that after a refresh, the user will try to continue using the application and would get a:
java.lang.IllegalStateException - duplicate Id for a component
in the browser.
Thanks!
Don't bind physically different components by binding to one and same bean property.
If you want a smart (knowledgeable) way to overcome this, add seam to your jsf application. They have solved the backbutton problems in JSF
Related
I have a problem with refreshing a single Liferay portlet. I wrote a bit of javascript code to refresh a single Liferay portlet every 120s:
function refreshPortlet() {
Liferay.Portlet.refresh("SOME_KEY")
};
setInterval("refreshPortlet()", 120000);
It works fine and the portlet refreshes, but the problem is that content of the portlet does not. I tried to clear the cache of the portlet with WebCachePoolUtil:
function refreshPortlet() {
WebCachePoolUtil.remove("SOME_KEY");
Liferay.Portlet.refresh("SOME_KEY")
};
setInterval("refreshPortlet()", 120000);
But now the function does not execute at all. Any hints?
Thanks in advance,
Stjepko
WebCachePoolUtil is a Java class, thus not available on the JS side. The reason the method is not executing is that it's running into the unavailability of that class.
If you want to execute browser-side code like you did, you'd need to identify where caching is done - e.g. on the browser or on the server. Observe your Developer Tool's network tab and inspect what's going across the wire.
Depending on the portlet that you're trying to refresh - specifically if it's a custom portlet - I'd recommend to implement Ajax explicitly and refresh either from a REST API or through the portlet's serveResource method.
I am developing an application on xpages and I have the following problem:
I use dynamic view panel with customizer bean. The customizer bean is based on the Jesse Gallagher bean available on GitHub (https://github.com/jesse-gallagher/Domino-One-Offs/blob/master/mcl/reports/DynamicViewCustomizer.java).
The problem is that after a few minutes of inactivity in the application, the navigation components (Pager Expand / Collapse, Pager, and PagerSizes) stop responding. The document access link works normally. If a refresh is run in the browser, the navigation components will work again.
If I remove the bean customizer the problem does not happen.
Does anyone know what the cause of the problem is and how to solve it?
Thaks a lot!
Marcus
Put Keep Session Alive controll from Extension Library to your page and set the delay for example to 60s. If this helps, you can change this to higher value.
The real cause of the problem was that I was adjusting some component and testing at the same time, without giving a reload in the application in the browser. This causes the behavior of the application to be abnormal. That way if you are testing and concurrently changing something in some component of the application, reload the application in the browser.
when is a view scope in an Domino XPage application lost by timeout, when the page is not accessed anymore? Is there a timeout? Or are they lost not until the session is closed (because of a logout or of the timeout)?
I know, that there is the server page persistence configuration in the Xsp Properties. But when is the scope lost, if you do nothing in the browser? You don't work in other tabs, so that there are not too much pages. (Is there an event listener for that, that allows me to print this out?)
Thanks in advance
AFAIK a viewScope object cannot live longer than the user's session. In addition it is bound to the current page's rendering for a given user.
This basically means that there are three options to kill a viewScope object:
move on to a different page
ask for a new rendition of the same page (like re-entering the same URL etc,; in fact this is the same as #1)
terminate the session by logging out, closing the browser etc.
You might want to try youself by building some test pages with a computed field bound to a viewScope variable; make sure that the variable is set through a button or the likes. Another option is to implement the Xpages debug toolbar available from openNTF.
A very simple explanation of all 4 scopes can be found here: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/xpages-scoped-variables.htm, but you might be aware of that already.
I have a wizard based on Spring MVC. To store the user input i have a RegisterCustomerForm object saved in session.
Everything works fine if i finish the wizard by clicking "finish" or "cancel". But if the user leaves the wizard by just clicking on some other link i want to remove the session attribute too. Something like a conversation scope i guess.
Is there any good way to achieve this behaviour?
If you can use Spring 3.1, you may take advantage of RedirectAttributes which is available as of this version. An example that demonstrates how to use the feature.
I was making some test with my JSF-app and when I tried it in the same web-browser on different tabs, in all tabs the last session was present.
How can I prevent this?
That isn't possible without hacking/changing the browser. But this really shouldn't matter. If that causes unintuitive behaviour in your JSF application (e.g. data of one tab is been redisplayed in another tab), then you were apparently storing view scoped data in session scoped beans. You should store view scoped data in view scoped beans instead.
Or if it is purely intended for testing purposes (i.e. you just wanted to test physically separate user sessions), then you should use physically separate browsers. E.g. one Firefox and one Chrome.
Or if you absolutely need to have "one user session per tab/window", then store the logged-in user in a view scoped bean instead of a session scoped bean and exclusively use ajax postbacks to navigate through pages (SPA - Single Page Application).
See also:
How to choose the right bean scope?
How do servlets work? Instantiation, sessions, shared variables and multithreading
How to ajax-refresh dynamic include content by navigation menu? (JSF SPA)