views:

260

answers:

3

When i hit a link a window popup is opened.I am having a session managed bean that loads a java.util.List.It is taking few seconds to load that list.

when i click the link twice i am getting concurrent modification exception. because the page is in session mode and first request is still loading the List, before it ends the second request tries to update the list.

I have two possible solution in hand

1) introducing synchronized block

Question : Introducing synchronized block leads to performance issue in multithread environment?

2) javascript to disable the link once it clicked.

problem : Not a good option because we need to restore the state of javascript once the popup is loaded. There is a possibility that the link is disabled forever if the popup window terminated abnormally.

Is there any other solution for this issue?

+1  A: 

One alternate solution is make the POPUP window modal window means the parent window will be blurred/ overshadowed till Pop up is closed. search for JavaScript code.

GustlyWind
Richfaces already provide a modal popup (modalPanel). Others librairies may also provide such component.
romaintaz
i am not allowed to use modal window.! ;(
Madhu
A: 

Choose 2nd option.

adatapost
Describing the choice would have been a better option! It isn't obvious why you're suggesting the 2nd option.
Iravanchi
+2  A: 

I'd choose option 1. synchronise on something in the session or on the session bean it's self. In a single server environment this should be pretty safe but in a cluster which isn't using sticky sessions you will have to look for a better singleton.

The performance shouldn't be effected as you will be synchronising for each user session for that particular session bean and if there is no contention the cost isn't worth thinking about.

Gareth Davis