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

<wicket:enclosure> bug, still calls getObject() on enclosed Models even if the content isn't rendered

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.3.0-rc1
    • 1.3.0-final
    • wicket
    • None
    • n/a

    Description

      Steps to reproduce:

      • Create a quickstart project:

      mvn archetype:create -DarchetypeGroupId=org.apache.wicket \
      -DarchetypeArtifactId=wicket-archetype-quickstart \
      -DarchetypeVersion=1.3.0-rc1 \
      -DgroupId=no.sysedata \
      -DartifactId=enclosurebug

      mvn eclipse:eclipse

      • Add two labels to HomePage.java. Let Label1 return isVisible=false, and implement a Model where getObject() writes to stdout for Label2:

      package no.sysedata;

      import org.apache.wicket.PageParameters;
      import org.apache.wicket.markup.html.basic.Label;
      import org.apache.wicket.markup.html.WebPage;
      import org.apache.wicket.model.Model;

      public class HomePage extends WebPage {
      private static final long serialVersionUID = 1L;

      public HomePage(final PageParameters parameters) {
      add(new Label("label1") {
      @Override public boolean isVisible()

      { return false; }

      });

      add(new Label("label2", new Model() {
      @Override public Object getObject()

      { System.out.println("Getting object of model 2"); return "MODEL2 OBJECT"; }

      }));
      }
      }

      • In HomePage.html, add an enclosure around the two labels and let label1 be the controlling component for the enclosure:

      <html>
      <head>
      <title>Wicket Enclosure Bug</title>
      </head>
      <body>
      <wicket:enclosure child="label1">
      <span wicket:id="label1">Label 1</span>
      <span wicket:id="label2">Label 2</span>
      </wicket:enclosure>
      </body>
      </html>

      • When you run the project, you'll get the following on stdout:

      "Getting object of model 2"

      And the rendered HTML when hitting the homepage is:

      <html>
      <head>
      <title>Wicket Enclosure Bug</title>
      </head>
      <body>
      <wicket:enclosure child="label1"></wicket:enclosure>
      </body>
      </html>

      If I add:

      @Override protected void init()

      { getMarkupSettings().setStripWicketTags(true); }

      to WicketApplication.java, the markup is:

      <html>
      <head>
      <title>Wicket Enclosure Bug</title>
      </head>
      <body>

      </body>
      </html>

      .. but the stdout is still the same.

      Attachments

        Activity

          People

            jdonnerstag Juegen Donnerstag
            edvin Edvin Syse
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: