Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I put html and java files in the same package (folder) in Apache Wicket?

Tags:

java

wicket

I wonder if there is an example which html files and java files are resides in different folders.

like image 360
Lurtz Avatar asked Dec 06 '22 07:12

Lurtz


1 Answers

I don't recommend using a separate page directory unless you are quite comfortable with how resource streams work, which I am not.

The vast majority of wicket projects I have seen keep class and html files in the source directory. I tried separating them myself but then found that getting my hands on other resources, like images and such, was a hassle; so, I wound up putting those resources in the package directory - in the end I had resources in several different places and it was more of a mess than putting everything in package directory would have been.

That said, here's the code I used to put my html templates in a separate folder. It should be added to Init() in your application class.

IResourceSettings resourceSettings = getResourceSettings();
resourceSettings.addResourceFolder("pages"); //the full path to your folder, relative to the context root
resourceSettings.setResourceStreamLocator((IResourceStreamLocator) new PathStripperLocator());

https://cwiki.apache.org/confluence/display/WICKET/Control+where+HTML+files+are+loaded+from has a tutorial on this.

like image 122
Loren_ Avatar answered Mar 22 '23 22:03

Loren_