You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Pierre Goupil <go...@gmail.com> on 2014/02/22 02:17:06 UTC

get page instance in AtmosphereRequestHandler

Good evening,

I'm trying to implement the unit test functionality of Wicket-Atmosphere.
I'm stuck on a silly thing.

I have this code in the class AtmosphereRequestHandler:

    @Override
    public void respond(final IRequestCycle requestCycle)
    {
        final Page page = (Page)Application.get().getMapperContext()
                .getPageInstance(this.pageKey.getPageId());
        final AjaxRequestTarget target =
WebApplication.get().newAjaxRequestTarget(page);
        this.executeHandlers(target, page);
    }

The page is always null, so I got an exception at the target creation,
saying page can not be null. But I'm sure the pageId I provide is OK.

Any idea?

Regards,

Pierre

Re: get page instance in AtmosphereRequestHandler

Posted by Pierre Goupil <go...@gmail.com>.
Well, that's what I did, indeed. But it wasn't enough. I've found a way, I
need more deep testing of it, but for the moment it looks OK.

Regards,

Pierre



On Mon, Feb 24, 2014 at 9:07 AM, Martin Grigorov <mg...@apache.org>wrote:

> Hi,
>
> You should have started a page before sending websocket requests to it, as
> in the real usage.
> By using tester.startPage(thePage) Wicket will store the page in
> MockPageManager and later you can find it by its id.
>
> Martin Grigorov
> Wicket Training and Consulting
>
>
> On Sat, Feb 22, 2014 at 5:13 PM, Pierre Goupil <goupilpierre@gmail.com
> >wrote:
>
> > Hi,
> >
> > In fact, it is this code:
> >
> > Session.get().getPageManager().getPage(pageId);
> >
> > (excerpt from DefaultMapperContext#getPageInstance(final int pageId))
> >
> > which returns null: the Session.get().getPageManager() contains no pages
> > when I'm in my Atmosphere context.
> >
> > Any thoughts, please?
> >
> > Kind regards,
> > Pierre
> >
> >
> >
> >
> >
> > On Sat, Feb 22, 2014 at 2:17 AM, Pierre Goupil <goupilpierre@gmail.com
> > >wrote:
> >
> > > Good evening,
> > >
> > > I'm trying to implement the unit test functionality of
> Wicket-Atmosphere.
> > > I'm stuck on a silly thing.
> > >
> > > I have this code in the class AtmosphereRequestHandler:
> > >
> > >     @Override
> > >     public void respond(final IRequestCycle requestCycle)
> > >     {
> > >         final Page page = (Page)Application.get().getMapperContext()
> > >                 .getPageInstance(this.pageKey.getPageId());
> > >         final AjaxRequestTarget target =
> > > WebApplication.get().newAjaxRequestTarget(page);
> > >         this.executeHandlers(target, page);
> > >     }
> > >
> > > The page is always null, so I got an exception at the target creation,
> > > saying page can not be null. But I'm sure the pageId I provide is OK.
> > >
> > > Any idea?
> > >
> > > Regards,
> > >
> > > Pierre
> > >
> >
> >
> >
> > --
> > "Un truc bien avec la musique, c'est que quand elle te frappe, tu n'as
> pas
> > mal.
> > Alors frappez-moi de musique !
> > Frappez-moi de musique, maintenant !"
> >
> > (Bob Marley : "Trenchtown Rock")
> >
>



-- 
"Un truc bien avec la musique, c'est que quand elle te frappe, tu n'as pas
mal.
Alors frappez-moi de musique !
Frappez-moi de musique, maintenant !"

(Bob Marley : "Trenchtown Rock")

Re: get page instance in AtmosphereRequestHandler

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

You should have started a page before sending websocket requests to it, as
in the real usage.
By using tester.startPage(thePage) Wicket will store the page in
MockPageManager and later you can find it by its id.

Martin Grigorov
Wicket Training and Consulting


On Sat, Feb 22, 2014 at 5:13 PM, Pierre Goupil <go...@gmail.com>wrote:

> Hi,
>
> In fact, it is this code:
>
> Session.get().getPageManager().getPage(pageId);
>
> (excerpt from DefaultMapperContext#getPageInstance(final int pageId))
>
> which returns null: the Session.get().getPageManager() contains no pages
> when I'm in my Atmosphere context.
>
> Any thoughts, please?
>
> Kind regards,
> Pierre
>
>
>
>
>
> On Sat, Feb 22, 2014 at 2:17 AM, Pierre Goupil <goupilpierre@gmail.com
> >wrote:
>
> > Good evening,
> >
> > I'm trying to implement the unit test functionality of Wicket-Atmosphere.
> > I'm stuck on a silly thing.
> >
> > I have this code in the class AtmosphereRequestHandler:
> >
> >     @Override
> >     public void respond(final IRequestCycle requestCycle)
> >     {
> >         final Page page = (Page)Application.get().getMapperContext()
> >                 .getPageInstance(this.pageKey.getPageId());
> >         final AjaxRequestTarget target =
> > WebApplication.get().newAjaxRequestTarget(page);
> >         this.executeHandlers(target, page);
> >     }
> >
> > The page is always null, so I got an exception at the target creation,
> > saying page can not be null. But I'm sure the pageId I provide is OK.
> >
> > Any idea?
> >
> > Regards,
> >
> > Pierre
> >
>
>
>
> --
> "Un truc bien avec la musique, c'est que quand elle te frappe, tu n'as pas
> mal.
> Alors frappez-moi de musique !
> Frappez-moi de musique, maintenant !"
>
> (Bob Marley : "Trenchtown Rock")
>

Re: get page instance in AtmosphereRequestHandler

Posted by Pierre Goupil <go...@gmail.com>.
Hi,

In fact, it is this code:

Session.get().getPageManager().getPage(pageId);

(excerpt from DefaultMapperContext#getPageInstance(final int pageId))

which returns null: the Session.get().getPageManager() contains no pages
when I'm in my Atmosphere context.

Any thoughts, please?

Kind regards,
Pierre





On Sat, Feb 22, 2014 at 2:17 AM, Pierre Goupil <go...@gmail.com>wrote:

> Good evening,
>
> I'm trying to implement the unit test functionality of Wicket-Atmosphere.
> I'm stuck on a silly thing.
>
> I have this code in the class AtmosphereRequestHandler:
>
>     @Override
>     public void respond(final IRequestCycle requestCycle)
>     {
>         final Page page = (Page)Application.get().getMapperContext()
>                 .getPageInstance(this.pageKey.getPageId());
>         final AjaxRequestTarget target =
> WebApplication.get().newAjaxRequestTarget(page);
>         this.executeHandlers(target, page);
>     }
>
> The page is always null, so I got an exception at the target creation,
> saying page can not be null. But I'm sure the pageId I provide is OK.
>
> Any idea?
>
> Regards,
>
> Pierre
>



-- 
"Un truc bien avec la musique, c'est que quand elle te frappe, tu n'as pas
mal.
Alors frappez-moi de musique !
Frappez-moi de musique, maintenant !"

(Bob Marley : "Trenchtown Rock")