Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2617

ModalWindow can't be shown when it is rendered with ajax request

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4.4
    • 1.4.5
    • wicket
    • None

    Description

      Regression appeared with 1.4.4 release, in previous releases all worked fine.

      I load page in two requests. First one loads very small html, which then loads remaining part with ajax request.
      (I do so to pass parameters after '#' to server in similar way as it is done in gmail, but there are other reasons to render ModalWindow with ajax request).
      ModalWindow is rendered (but not shown) with second (ajax) request.

      The private variable "shown" is set to true:
      protected void onBeforeRender()
      {
      shown = makeContentVisible();

      Because of following implementation of makeContentVisible method:
      protected boolean makeContentVisible()

      { // if user is refreshing whole page, the window will not be shown return getWebRequest().isAjax(); }

      But when I call "show" method nothing happens:
      public void show(final AjaxRequestTarget target)
      {
      if (shown == false)

      { getContent().setVisible(true); target.addComponent(this); target.appendJavascript(getWindowOpenJavascript()); shown = true; }

      }

      Actually there are two problems:
      1) behavior has changed
      2) I didn't find safe workaround for this problem.
      Unsafe workaround as follows, notice, it can break with next wicket release since base "show" method is not called in sub class:

      class MyModalWindow extends ModalWindow {
      protected boolean visible = false;

      @Override
      protected boolean makeContentVisible()

      { return visible; }

      @Override
      public void show(org.apache.wicket.ajax.AjaxRequestTarget target)

      { visible = true; getContent().setVisible(true); target.addComponent(this); target.appendJavascript(getWindowOpenJavascript()); }

      ;

      @Override
      public void close(AjaxRequestTarget target)

      { visible = false; super.close(target); }

      }

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            mihasik Michael Mikhulya
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: