Wicket gate: link

I am trying the following example. ChangeTextOnClick.html works great because it is in the same directory as the file containing the following snippet (WicketLink.html). But HelloWorld.html does not work, as in another package. How can I link to a page in another 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 following 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 
+4
source share
3 answers

It turns out my guess was right, so here is the answer:

Wicket uses / as a 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> 

- one solution or use of 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> 
+5
source

In Wicket, you usually link to another html file using a link in Java so that Wicket generates href for you. You can mount the page under the patch URL (called Bookmarkable Link because they are independent of the user's session) or just use the link.

To bookmark with a bookmark, you must 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); } } 

In this case, you can always reach these 2 pages under the specified URL.

You can create a link pointing there using this in 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 do not want the links to be classified, you do not need the mountBookmarkablePage materials in init () and use the link instead of the BookmarkablePageLink bookmark.

Look at Wicket wicki, you will find there a lot of useful information.

+10
source

The above answer is perfect. It must not only be located in another folder in the project, but it can also be located anywhere in the folder in the system. In this case, you can refer to this file if the configuration is performed correctly in the WicketApplication file.

0
source

Source: https://habr.com/ru/post/1335661/


All Articles