Friday, December 21, 2007

Firefox causes Wicket to re-render page

I had a problem with my Wicket application where the page was being rendered twice, but the DOM in my browser wasn't getting updated. After much hair loss, I discovered it wasn't a wicket thing at all. Nor was it anything wrong with my application. It was something specific to Firefox.

It turns out that Firefox makes an additional page request if there is an image on the page with an empty source. I had this because my database had null values for the images to display, so this was rendered:
<img wicket:id="" src=""/>
Firefox makes two requests to the page if this is the case. The first has this in the
request headers:
Accept: text/xml,application/xml
,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
The browser then makes a second request due to the src="", with this in the request headers:
Accept: image/png,*/*;q=0.5
The result is that Wicket renders the page again, but Firefox doesn't update its DOM with the new HTML (and thus new Link URLs). So Wicket was doing what it should.

The solution was to make sure that my application does not output src="" for the images. Also, I found the same problem will take place for images defined in CSS files if the source is "".

No comments:

Post a Comment