Here is a super-simple example of creating a custom request listener. First, you create the new listener interface:
public interface IHelloListener extends IRequestListener { public static final RequestListenerInterface INTERFACE = new RequestListenerInterface( IHelloListener.class); void onHello(); } Note that it has a single method without parameters. This is a requirement as you can read from IRequestListener's JavaDocs. The other thing to note is the INTERFACE field; by instantiating a RequestListenerInterface you register the interface, and the field exposes a handle for constructing URLs using RequestCycle's UrlFor methods. Next, I simple patched the HelloWorld example like this: public class HelloWorld extends WicketExamplePage implements IHelloListener { public HelloWorld() { add(new Label("message", "Hello World!")); WebMarkupContainer link = new WebMarkupContainer("link"); link.add(new SimpleAttributeModifier("href", RequestCycle.get().urlFor(this, IHelloListener.INTERFACE))); add(link); } public void onHello() { RequestCycle.get().setRequestTarget(new IRequestTarget() { public void detach(RequestCycle requestCycle) { } public void respond(RequestCycle requestCycle) { requestCycle.getResponse().write("<html><body>HELLO!</body></html>"); } }); } } The html is straightforward, with the link defined like: <a wicket:id="link">click me</a> And that's all there is to it: we created a new kind of listener for requests. Note that it is (still) bound to a page (or any arbitrary component). It is entirely possible to decouple this further, from the top of my head by providing a custom WebRequestCodingStrategy and override doEncode for your specific purpose. But if you are doing that, you probably might as well just create your own servlet. It is certainly a design goal for Wicket to be very extensible. However, it is *also* a goal to have different levels in our abstraction. I agree with Igor that having services so upfront in the architecture is or at least encourages scope creep, as it makes it too obvious for users to start coding their own as if they were a replacement for servlets and don't take the time to fully get into the component mind set. As you can see from the example, there are pretty much no limits to what you can do with Wicket, but we hope that doing things like creating custom listeners are only used as a last resort. And if you think you find a really good use, we'd appreciate it if you would communicate it as there might be something we missed and can result in a useful addition to Wicket. My 2c, and again, if you have good and specific use cases, share them :) Eelco ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user