JSF concurrency question

When I click on the link, a popup opens. I have a session managed bean that loads java.util.List.It takes a few seconds to load this list.

when i click the link twice i get a concurrent modification exception. because the page is in session mode and the first request is still loading the list before it completes the second request tries to update the list.

I have two possible solutions:

1) introducing a synchronized block

Q: Does the introduction of a synchronized block cause performance issues in a multithreaded environment?

2) javascript to disable the link after clicking it.

Problem: Not a good option because we need to restore the javascript state after the popup is loaded. There is a possibility that the link is disabled permanently if the popup terminated abnormally.

Is there any other solution for this problem?

+2


source to share


4 answers


I would choose option 1. sync something in the session or in the session bean itself. In one server environment this should be pretty secure, but in a cluster that doesn't use sticky sessions, you need to look for the best singleton.



Performance doesn't need to be enforced, as you will be syncing for every user session for a given bean session, and if there are no assertions, the cost is not worth considering.

+2


source


One alternative solution is that the POPUP window modal means the parent window will be blurred / darkened until the popup is closed. search for JavaScript code.



+1


source


Choose the second option.

0


source


if you are using rich faces you can use rich faces a4j library and re-get popup message

<a4j:commandButton id="popupLinkId" onlick="window.open("popupLink");return false;"  reRender="popupLinkId" />

      

Here a4j is ajax for jsf rich person library. See http://livedemo.exadel.com/richfaces-demo/richfaces/support.jsf;jsessionid=B9DFBAF3AFD62C96B94EEC67FC4645A5?c=support&tab=usage for details .

0


source







All Articles