Hi,
working on Wicket UI reminds me a little of my old times
building Swing desktop apps.
One thing that occurred to me is that I used to start
working on a new component by fleshing it just its structure,
and started testing right away by placing a little "main"
directly in the component to run it in isolation.
This of course worked only in the initial phases of development,
once I started hooking the component on the persistence backend
that became harder and harder (unless one mocked per persistence),
but it was a nice way to quickly check the basics of the component
itself.
I was wondering if anything similar was possible for Wicket
webapps, and after some fiddling, I concluded that yeah,
it was.
So I put togheter the attached classes that allow one to
just add a main and run a very quick Wicket webapp around
a single, still non Catalog dependent component.
I used it to quickly test a server side file browser
I'm building in my spare time and it worked nicely.
All I had to do in order to check interactively my
file list viewer was to add the following to its code:
public static void main(String args) {
WicketTestApplication.start(new IComponentFactory() {
public Component createComponent(String id) {
FileProvider provider = new FileProvider(new File("c:/progetti/gisData"));
provider.setSort(new SortParam(FileProvider.NAME, true));
return new FileDataView(id, provider) {
@Override
protected void linkNameClicked(File modelObject,
AjaxRequestTarget target) {
System.out.println(modelObject.getAbsolutePath());
}
};
}
});
}
And voilĂ , you run it, you have a file browser on the specified
path that responds to the user clicks.
I was considering contributing this back to GeoServer:
- do people want it
- where do we put it?
The second question is a harder one, as it requires jetty
in the classpath. Maybe we can roll a module of its own,
and people add it as a provided dependency?
The testing "main" are imho to be removed or commented out
once they served their purpose, but in the meantime the
modules do need those classes and Jetty in the classpath.
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
(attachments)
IComponentFactory.java (534 Bytes)
TestHomePage.java (1.03 KB)
WicketTestApplication.java (2.7 KB)
TestHomePage.html (75 Bytes)