Wicket Guard #1

Wicket Guard #1 – Cannot use wicket:id elements in substituted (replaced) panels.

I was using a panel html, but wanted to have the flexibility of designing it in main page also. So I copy the panel’s contents in the Main page too just for designing. This panel content should eventually be replaced by Wicket at runtime.

Panel.html

<wicket:panel>
  <div id="panelContainer">
    <ul>
      <li wicket:id="element">...</li>
    </ul>
  </div>
</wicket:panel>

Main.html

<div id="panel" wicket:id="panel">
    <ul>
      <li wicket:id="element">...</li>
    </ul>
</div>

When I ran the above code, wicket complained that <div> element does not have a close tag. Wicket obviously replaces the contains within div#panel in the Main.html with the Panel.html contents. Then why would it complain? After a bit of digging, found out that the Main.html also contains a not-so-obvious <li wicket:id=”element”>. Wicket does not blindly replace the panel within div#panel, instead it errors out if the element within that has a wicket:id.

Corrected Main.html

<div id="panel" wicket:id="panel">
    <ul>
      <li>...</li>
    </ul>
</div>

So now I have the ability to design Main.html and still have the panel in a separate file.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: