javascriptiframewicketdomready

Wicket fails to reload the page onSubmit when the page contains iframe


The page fails to be reloaded completely when the response contains iframe after submitting the form with a Wicket Button. The problem is that wicket tries to bind some event listeners on window.domready, but it fails by saying "Cannot bind a listener for event "change" on element "topRightItemTypeChoice7" because the element is not in the DOM"

I have analyzed the response text with httpfox plugin and the component with this id exists in the response.

Below is the JS snippet by Wicket which tries to bind the event

Wicket.Event.add(window, "domready", function(event) { 
$('#topRightItemTypeChoice7').uniform();;
Wicket.Ajax.ajax({"c":"topRightItemTypeChoice7","ad":true,"u":"./PrDashBoardConfigurationPage?5-2.IBehaviorListener.0-container-configuratorForm-topRightDiv-topRightItemTypeChoice","e":"change","m":"POST"});;

The html component from the response

<select name="topRightDiv:topRightItemTypeChoice" id="topRightItemTypeChoice7">

Everything works fine when I simply remove the iframe from the page. Any idea what different does make iframe for window.domready ?


Solution

  • I will try to clarify my own question, because I found where was the issue. Maybe someone would like to know this. The problem was thatreplaceComponentTagBody method provided by Wicket. I didn't mention in the question about usage of this method, which could make easier for the people who were trying to answer. I was using the method on this way

    replaceComponentTagBody(markupStream, openTag, "<iframe id=''/>");
    

    instead of

    replaceComponentTagBody(markupStream, openTag, "<iframe id=''></iframe>");
    

    The difference was in iframe's closing tag, where replaceComponentTagBody was sensitive to this point and didn't allow Wicket to render the remaining HTML code.