I am trying out the following example. ChangeTextOnClick.html works fine as it is in the same dir as the file that contains the following snippet (WicketLink.html). But HelloWorld.html does not work as it is in another package. How do i refer to page on a different package.
<wicket:link>
<ul>
<li>
<a href="ChangeTextOnClick.html">Change Text On Click</a>
<a href="com.merc.wicket.main/HelloWorld.html">Back</a>
</li>
</ul>
</wicket:link>
my pages are in the follow dir structure
com.merc.wicket.link.WicketLink.java and .html
com.merc.wicket.link.ChangeTextOnClick.java and .html
com.merc.wicket.main.HelloWorld.java and .html
In Wicket, you would normally reference another html file using a Link in Java to let Wicket generate the href for you. You can mount a Page under a fix URL (called Bookmarkable Link, as they are independent from the user session) or just use a Link.
For a Bookmarkable Link, you would do the following in the init() of your Wicket application class:
public class WicketApplication extends WebApplication{
protected void init() {
super.init();
mountBookmarkablePage("/ChangeTextOnClick", ChangeTextOnClick.class);
mountBookmarkablePage("/HelloWorld", HelloWorld.class);
}
}
With this, you can always reach those 2 Pages under the the URL given.
You can create a link pointing there using this in a MyPage.java:
add(new BookmarkablePageLink<ChangeTextOnClick>("myExampleLink"
,ChangeTextOnClick.class)
and in the corresponding MyPage.html:
<a href="thisGetsReplacedAtRuntime"
wicket:id="myExampleLink">Change Text On Click</a>
If you don 't want the Links to be bookmarkable, you don 't need the mountBookmarkablePage stuff in the init() and use a a Link instead of a BookmarkablePageLink.
Have a look at the Wicket wicki, you will find lots of helpful information there.
It turns out my guess was correct so here it is as an answer:
Wicket uses /
as path separator, not .
.
<wicket:link>
<ul>
<li>
<a href="ChangeTextOnClick.html">Change Text On Click</a>
<a href="/com/merc/wicket/main/HelloWorld.html">Back</a>
</li>
</ul>
</wicket:link>
is one solution, or using relative paths:
<wicket:link>
<ul>
<li>
<a href="ChangeTextOnClick.html">Change Text On Click</a>
<a href="../main/HelloWorld.html">Back</a>
</li>
</ul>
</wicket:link>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With