yeah, dont think we ever thought about doing that...please open a jira
issue. it is probably something we should support.

-igor


On 6/22/07, Paolo Di Tommaso <[EMAIL PROTECTED]> wrote:

The quick start was in the included email, anyway here it is again ..

public interface IHelloListener extends IRequestListener
{
        public static final RequestListenerInterface INTERFACE = new
RequestListenerInterface(
                        IHelloListener.class);

        void onHello();
}


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 problem seems that it cannot work if the implementing listener is the
page itself. But I've just discovered that it works fine using a component
insted of a the page.


Paolo


On 6/22/07, Paolo Di Tommaso <[EMAIL PROTECTED]> wrote:
>
> I'm trying to create a custom request listener like the following code,
> but something is wrong because I always get the "Page Expired" error page
> when I'm invoking the custom listener (clicking on the link).
>
> Any ideas to make it work?
>
> Thank you, Paolo
>
>
> On 3/16/07, Eelco Hillenius < [EMAIL PROTECTED] > wrote:
> >
> > 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
> >
> >

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to