Monday 28 December 2009

Struts2 Double Click issue in Firefox

Problem:
The problem i faced was that some of my struts2 actions are being called twice or sometimes thrice in Firefox only when clicked once from my website or UI. This is the only place where IE was working perfectly fine and FF was troubling..lolz (and because of it i was more worried).


Symptoms:


I took myself in debugging mode and was seeing that actions are being called twice. Secondly my log4j logging was also proving this.
I used FireBug to see the how many hits are being generated and it showed that as soon as i clicked once on the hyperlink, two (or three in one case) hits generated. So the issue was finally proved that it is due to some UI stuff.


Due to it for a glimpse of a second i was being shown some validation error(as when the form is submitted second time, it was submitted with null values) plus things got worst when my code started showing exception(Due to null values)


Solution:
After googling for a week(although for sometime i dropped this issue and got involved in other but it took a week) i found its solution that this happens due to empty image tag  <img src=""/>


but the thing was i wasnt using any empty image tag in the whole page. But after some help i figured it out that it was due to background-image


Actually it happens because for images another call is being generated and as we are specifying that background image is null therefore it was hitting the default action we were specifying in s:submit tag


About server being hit thrice, i did a mistake that instead of defining just only href or onClick...i defined both of them. So the problem got resolved when i remove one of them