Note that there are some explanatory texts on larger screens.

plurals
  1. PODecorator Component in Wicket
    text
    copied!<p>Is it possible to implement some kind of decorator component in wicket ? Specially while honoring the id of the decorated component ?</p> <p>Currently i try to solve this using a Border Component acting as a decorator:</p> <p>Given:</p> <pre><code>public XXXPage() { MyBorder border = new MyBorder("xxx"); border.add( new Label("xxx", "Foo") ); // label just as simplification. Its really a Component that we want to surround the anchor (linkify) around. add(border); } </code></pre> <p>XXXPage.html</p> <pre><code>&lt;body&gt; &lt;span wicket:id="xxx"/&gt; &lt;/body&gt; </code></pre> <p>MyBorder.html</p> <pre><code>&lt;wicket:border&gt; &lt;a wicket:id="link"&gt;&lt;wicket:body/&gt;&lt;/a&gt; &lt;/wicket:border&gt; </code></pre> <p>MyBorder.java</p> <pre><code>public MyBorder(String id) { super(id); AjaxLink link = new AjaxLink("link") { @Override public void onClick(AjaxRequestTarget arg0) { } }; add(link); link.add(getBodyContainer()); // from javadoc of Wicket's Border } </code></pre> <p>Gives:</p> <pre><code>org.apache.wicket.WicketRuntimeException: The component(s) below failed to render. A common problem is that you have added a component in code but forgot to reference it in the markup (thus the component will never be rendered). 1. [Component id = xxx] at org.apache.wicket.Page.checkRendering(Page.java:1182) </code></pre> <p>So in essence, the xxx component should be wrapped in a transparent manner with a link component. This xxx is out of control.</p> <p>In a "banana wicket" implementation this would be a possible pseudo code:</p> <pre><code>Component wrapWithAction(Component a) { // now wrap Link b = new Link() { // handle link onClick and all that } b.wrap(a); return b; } // </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload