Hi,
I've been looking into ways to have Wicket automatically generate
nice looking mount points without having to manually register or
mount the urls. The thing did not go well, it is actually doable
but I found myself lost into some hairy code in the Wicket
WebRequestCodingStrategy class, which is not really meant for
easy subclassing, so I decided to stay away from it :)
In any case, if someone wants to try, have a look at
WebRequestCodingStrategy and the only subclass of it,
UrlCompressingWebCodingStrategy, which to be used actually
needs also the UrlCompressingWebRequestProcessor class.
As an alternative I took David's patch and modified it
a bit so that:
- any page, not just menu pages, can be registered
and mounted with a nice path, by rolling PageInfo,
a MenuPaneInfo superclass that knows about mounting
- the nice path gets automatically computed, unless
manually overridden, from the class package and name
The strategy makes it so that a page class like:
org.geoserver.web.data.layer.LayerPage
gets a path like:
data/layer/layer
and thus it's available at:
http://host:port/geoserver/web/data/layer/layer
Basically the convention strips off org.geoserver.web
and Page and turns what remains in the path (thus the
double layer/layer, due to layer.LayerPage).
For the current menu pages we don't have to move a finger,
but to get nice looking urls we should enforce some
better convention on class names, something like:
org.geoserver.web.data.layer.LayerListPage
org.geoserver.web.data.layer.NewLayerPage
org.geoserver.web.data.layer.EditLayerPage
which would turn into the following urls:
http://host:port/geoserver/web/data/layer/layerlist
http://host:port/geoserver/web/data/layer/newlayer
http://host:port/geoserver/web/data/layer/editlayer
Also, in the web wms/wfs/wcs modules the root package
is like org.geoserver.w?s.web, to get good names we
should again uniform to the convention and use
org.geoserver.web.w?s instead.
So it's a bit of work, but nothing so hard, and would
result in a better uniformity in the code as well.
If we don't want to go down the convention path
PageInfo also allows to manually specify a mount path.
Opinions?
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
Index: core/src/main/java/org/geoserver/web/MenuPageInfo.java
===================================================================
--- core/src/main/java/org/geoserver/web/MenuPageInfo.java (revisione 12820)
+++ core/src/main/java/org/geoserver/web/MenuPageInfo.java (copia locale)
@@ -16,7 +16,7 @@
* @author David Winslow <[email protected]>
*/
@SuppressWarnings("serial")
-public class MenuPageInfo extends ComponentInfo<GeoServerBasePage> implements Comparable<MenuPageInfo> {
+public class MenuPageInfo extends PageInfo implements Comparable<MenuPageInfo> {
Category category;
int order;
String icon;
Index: core/src/main/java/org/geoserver/web/GeoServerApplication.java
===================================================================
--- core/src/main/java/org/geoserver/web/GeoServerApplication.java (revisione 12822)
+++ core/src/main/java/org/geoserver/web/GeoServerApplication.java (copia locale)
@@ -164,6 +164,12 @@
// we have our own application wide gzip compression filter
getResourceSettings().setDisableGZipCompression(true);
+
+ // mount all bookmarkable pages we know about
+ List<PageInfo> pages = getBeansOfType(PageInfo.class);
+ for (PageInfo info : pages) {
+ mountBookmarkablePage(info.getMountPath(), info.getComponentClass());
+ }
}
@Override
Index: core/src/main/java/org/geoserver/web/PageInfo.java
===================================================================
--- core/src/main/java/org/geoserver/web/PageInfo.java (revisione 0)
+++ core/src/main/java/org/geoserver/web/PageInfo.java (revisione 0)
@@ -0,0 +1,43 @@
+/* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
+ * This code is licensed under the GPL 2.0 license, available at the root
+ * application directory.
+ */
+package org.geoserver.web;
+
+/**
+ * Information about a page that should be mounted and thus have a pretty URL
+ *
+ * @author Andrea Aime - OpenGeo
+ */
+...@suppresswarnings("serial")
+public class PageInfo extends ComponentInfo<GeoServerBasePage> {
+ private static final String UI_PACKAGE_PREFIX = "org/geoserver/web/";
+ private static final int UI_PACKAGE_PREFIX_LENGTH = UI_PACKAGE_PREFIX.length();
+ String mountPath;
+
+ /**
+ * Returns the mount path for this page
+ * @return
+ */
+ public String getMountPath() {
+ if(mountPath == null) {
+ // strip off the common prefix
+ String path = getComponentClass().getName();
+ path = path.replace('.', '/');
+ if(path.startsWith(UI_PACKAGE_PREFIX)) {
+ path = path.substring(UI_PACKAGE_PREFIX_LENGTH);
+ }
+ // strip off the common suffix
+ if(path.endsWith("Page"))
+ path = path.substring(0, path.length() - 4);
+ // url's are rarely camel case
+ mountPath = path.toLowerCase();
+ }
+ return mountPath;
+ }
+
+ public void setMountPath(String mountPath) {
+ this.mountPath = mountPath;
+ }
+
+}
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel