You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Timm Helbig <ti...@th-hosting.net> on 2008/03/28 23:44:37 UTC

setResponsePage(Class c) versus setResponsePage(Page p)

Hi,

I have read several times in the mailing list, that it is bad to use 
setRespsonsePage(Page p). What is the backdraw compared to 
setResponsePage(Class c) ?

In my case a Form Submit redirects to another Page, that needs some initial 
data given through the Constructor, e.g. MyPage(MyInitialData data) {} .

Regards,
Timm

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setResponsePage(Class c) versus setResponsePage(Page p)

Posted by James Carman <ja...@carmanconsulting.com>.
On Sat, Mar 29, 2008 at 4:18 AM, Johan Compagner <jc...@gmail.com> wrote:
> yes it does
>  do you see the "ILinkListener" part is your browser url?
>  no because the cleanest url: wicket:interface=:15:::: is the
>  IRedirectListener but we dont print that in the url because that one is
>  assumed
>  if no interface string is given
>

Ok, my bad.  I just saw all those dots in the URL and assumed it was
the link listener's URL still.  That's good to know that if the
listener interface isn't included that it's the IRedirectListener.
Thanks for the explanation.  Sorry for the misinformation.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setResponsePage(Class c) versus setResponsePage(Page p)

Posted by Johan Compagner <jc...@gmail.com>.
yes it does
do you see the "ILinkListener" part is your browser url?
no because the cleanest url: wicket:interface=:15:::: is the
IRedirectListener but we dont print that in the url because that one is
assumed
if no interface string is given

johan


On Sat, Mar 29, 2008 at 1:43 AM, James Carman <ja...@carmanconsulting.com>
wrote:

> Nevermind, I thought it was a link listener URL, but maybe it's not.
> Here's what I'm seeing.  I have my home page (a quickstart app) set up
> to do a link to AnotherPage in two different ways:
>
>    public HomePage()
>    {
>        add(new Link("link1")
>        {
>            public void onClick()
>            {
>                setResponsePage(new AnotherPage());
>                setRedirect(true);
>            }
>        });
>        add(new Link("link2")
>        {
>            public void onClick()
>            {
>                setResponsePage(AnotherPage.class);
>                setRedirect(true);
>            }
>        });
>    }
>
> <html>
> <head>
>    <title>Wicket Quickstart Archetype Homepage</title>
> </head>
> <body>
> <a href="#" wicket:id="link1">Page Instance Link</a>
> <br/>
> <a href="#" wicket:id="link2">Class Link</a>
> </body>
> </html>
>
> I also have HomePage mounted as such (AnotherPage is in the same package):
>
> mount(new PackageRequestTargetUrlCodingStrategy("/home",
> PackageName.forClass(HomePage.class)));
>
> So, here's what I get when HomePage renders:
>
> <html>
> <head>
>    <title>Wicket Quickstart Archetype Homepage</title>
> </head>
> <body>
> <a href="../../?wicket:interface=:14:link1::ILinkListener::"
> wicket:id="link1">Page Instance Link</a>
> <br/>
> <a href="../../?wicket:interface=:14:link2::ILinkListener::"
> wicket:id="link2">Class Link</a>
> </body>
> </html>
>
> When I click link1, the browser's URL is:
>
> http://localhost:8080/myproject/?wicket:interface=:15::::
>
> When I click link2, the browser's URL is:
>
> http://localhost:8080/myproject/home/AnotherPage/
>
> So, it looked like a redirect wasn't happening in the first case.  Is it?
> On Fri, Mar 28, 2008 at 8:16 PM, James Carman
> <ja...@carmanconsulting.com> wrote:
> > Well, I tried it with doing setResponsePage(new MyOtherPage()) and URL
> >  still looked like the link listener URL.  But, when I did
> >  setResponsePage(MyOtherPage.class), the URL changed to whatever I
> >  mounted it to.  I assumed that meant that the redirect wasn't
> >  happening.  I could be wrong.
> >
> >
> >
> >
> >  On Fri, Mar 28, 2008 at 7:47 PM, Johan Compagner <jc...@gmail.com>
> wrote:
> >  > what do you mean redirect does't work?
> >  >  90% of the time if you do setResponsePage(new Page())
> >  >  a redirect is done anyway. (for example if you do that in onSubmit)
> >  >  To go around for example the double post problem if you go back in
> history
> >  >  or refresh the page.
> >  >
> >  >  johan
> >  >
> >  >  On Sat, Mar 29, 2008 at 12:15 AM, James Carman <
> james@carmanconsulting.com>
> >  >
> >  >
> >  > wrote:
> >  >
> >  >  > Oh, and redirect doesn't work with the Page version (at least in
> my
> >  >  > tests it didn't).
> >  >  >
> >  >  > On Fri, Mar 28, 2008 at 7:13 PM, James Carman
> >  >  > <ja...@carmanconsulting.com> wrote:
> >  >  > > If you need to initialize the page instance in some way (by
> passing
> >  >  > >  constructor params, for instance), you use the Page version.
>  The
> >  >  > >  other version just uses Class.newInstance() to instantiate the
> page
> >  >  > >  object.
> >  >  > >
> >  >  > >
> >  >  > >
> >  >  > >  On Fri, Mar 28, 2008 at 6:44 PM, Timm Helbig <
> >  >  > timm.helbig@th-hosting.net> wrote:
> >  >  > >  > Hi,
> >  >  > >  >
> >  >  > >  >  I have read several times in the mailing list, that it is
> bad to use
> >  >  > >  >  setRespsonsePage(Page p). What is the backdraw compared to
> >  >  > >  >  setResponsePage(Class c) ?
> >  >  > >  >
> >  >  > >  >  In my case a Form Submit redirects to another Page, that
> needs some
> >  >  > initial
> >  >  > >  >  data given through the Constructor, e.g.
> MyPage(MyInitialData data)
> >  >  > {} .
> >  >  > >  >
> >  >  > >  >  Regards,
> >  >  > >  >  Timm
> >  >  > >  >
> >  >  > >  >
> >  >  >
>  ---------------------------------------------------------------------
> >  >  > >  >  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >  >  > >  >  For additional commands, e-mail:
> users-help@wicket.apache.org
> >  >  > >  >
> >  >  > >  >
> >  >  > >
> >  >  >
> >  >  >
> ---------------------------------------------------------------------
> >  >  > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >  >  > For additional commands, e-mail: users-help@wicket.apache.org
> >  >  >
> >  >  >
> >  >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: setResponsePage(Class c) versus setResponsePage(Page p)

Posted by James Carman <ja...@carmanconsulting.com>.
Nevermind, I thought it was a link listener URL, but maybe it's not.
Here's what I'm seeing.  I have my home page (a quickstart app) set up
to do a link to AnotherPage in two different ways:

    public HomePage()
    {
        add(new Link("link1")
        {
            public void onClick()
            {
                setResponsePage(new AnotherPage());
                setRedirect(true);
            }
        });
        add(new Link("link2")
        {
            public void onClick()
            {
                setResponsePage(AnotherPage.class);
                setRedirect(true);
            }
        });
    }

<html>
<head>
    <title>Wicket Quickstart Archetype Homepage</title>
</head>
<body>
<a href="#" wicket:id="link1">Page Instance Link</a>
<br/>
<a href="#" wicket:id="link2">Class Link</a>
</body>
</html>

I also have HomePage mounted as such (AnotherPage is in the same package):

mount(new PackageRequestTargetUrlCodingStrategy("/home",
PackageName.forClass(HomePage.class)));

So, here's what I get when HomePage renders:

<html>
<head>
    <title>Wicket Quickstart Archetype Homepage</title>
</head>
<body>
<a href="../../?wicket:interface=:14:link1::ILinkListener::"
wicket:id="link1">Page Instance Link</a>
<br/>
<a href="../../?wicket:interface=:14:link2::ILinkListener::"
wicket:id="link2">Class Link</a>
</body>
</html>

When I click link1, the browser's URL is:

http://localhost:8080/myproject/?wicket:interface=:15::::

When I click link2, the browser's URL is:

http://localhost:8080/myproject/home/AnotherPage/

So, it looked like a redirect wasn't happening in the first case.  Is it?
On Fri, Mar 28, 2008 at 8:16 PM, James Carman
<ja...@carmanconsulting.com> wrote:
> Well, I tried it with doing setResponsePage(new MyOtherPage()) and URL
>  still looked like the link listener URL.  But, when I did
>  setResponsePage(MyOtherPage.class), the URL changed to whatever I
>  mounted it to.  I assumed that meant that the redirect wasn't
>  happening.  I could be wrong.
>
>
>
>
>  On Fri, Mar 28, 2008 at 7:47 PM, Johan Compagner <jc...@gmail.com> wrote:
>  > what do you mean redirect does't work?
>  >  90% of the time if you do setResponsePage(new Page())
>  >  a redirect is done anyway. (for example if you do that in onSubmit)
>  >  To go around for example the double post problem if you go back in history
>  >  or refresh the page.
>  >
>  >  johan
>  >
>  >  On Sat, Mar 29, 2008 at 12:15 AM, James Carman <ja...@carmanconsulting.com>
>  >
>  >
>  > wrote:
>  >
>  >  > Oh, and redirect doesn't work with the Page version (at least in my
>  >  > tests it didn't).
>  >  >
>  >  > On Fri, Mar 28, 2008 at 7:13 PM, James Carman
>  >  > <ja...@carmanconsulting.com> wrote:
>  >  > > If you need to initialize the page instance in some way (by passing
>  >  > >  constructor params, for instance), you use the Page version.  The
>  >  > >  other version just uses Class.newInstance() to instantiate the page
>  >  > >  object.
>  >  > >
>  >  > >
>  >  > >
>  >  > >  On Fri, Mar 28, 2008 at 6:44 PM, Timm Helbig <
>  >  > timm.helbig@th-hosting.net> wrote:
>  >  > >  > Hi,
>  >  > >  >
>  >  > >  >  I have read several times in the mailing list, that it is bad to use
>  >  > >  >  setRespsonsePage(Page p). What is the backdraw compared to
>  >  > >  >  setResponsePage(Class c) ?
>  >  > >  >
>  >  > >  >  In my case a Form Submit redirects to another Page, that needs some
>  >  > initial
>  >  > >  >  data given through the Constructor, e.g. MyPage(MyInitialData data)
>  >  > {} .
>  >  > >  >
>  >  > >  >  Regards,
>  >  > >  >  Timm
>  >  > >  >
>  >  > >  >
>  >  >  ---------------------------------------------------------------------
>  >  > >  >  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  >  > >  >  For additional commands, e-mail: users-help@wicket.apache.org
>  >  > >  >
>  >  > >  >
>  >  > >
>  >  >
>  >  > ---------------------------------------------------------------------
>  >  > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  >  > For additional commands, e-mail: users-help@wicket.apache.org
>  >  >
>  >  >
>  >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setResponsePage(Class c) versus setResponsePage(Page p)

Posted by James Carman <ja...@carmanconsulting.com>.
Well, I tried it with doing setResponsePage(new MyOtherPage()) and URL
still looked like the link listener URL.  But, when I did
setResponsePage(MyOtherPage.class), the URL changed to whatever I
mounted it to.  I assumed that meant that the redirect wasn't
happening.  I could be wrong.


On Fri, Mar 28, 2008 at 7:47 PM, Johan Compagner <jc...@gmail.com> wrote:
> what do you mean redirect does't work?
>  90% of the time if you do setResponsePage(new Page())
>  a redirect is done anyway. (for example if you do that in onSubmit)
>  To go around for example the double post problem if you go back in history
>  or refresh the page.
>
>  johan
>
>  On Sat, Mar 29, 2008 at 12:15 AM, James Carman <ja...@carmanconsulting.com>
>
>
> wrote:
>
>  > Oh, and redirect doesn't work with the Page version (at least in my
>  > tests it didn't).
>  >
>  > On Fri, Mar 28, 2008 at 7:13 PM, James Carman
>  > <ja...@carmanconsulting.com> wrote:
>  > > If you need to initialize the page instance in some way (by passing
>  > >  constructor params, for instance), you use the Page version.  The
>  > >  other version just uses Class.newInstance() to instantiate the page
>  > >  object.
>  > >
>  > >
>  > >
>  > >  On Fri, Mar 28, 2008 at 6:44 PM, Timm Helbig <
>  > timm.helbig@th-hosting.net> wrote:
>  > >  > Hi,
>  > >  >
>  > >  >  I have read several times in the mailing list, that it is bad to use
>  > >  >  setRespsonsePage(Page p). What is the backdraw compared to
>  > >  >  setResponsePage(Class c) ?
>  > >  >
>  > >  >  In my case a Form Submit redirects to another Page, that needs some
>  > initial
>  > >  >  data given through the Constructor, e.g. MyPage(MyInitialData data)
>  > {} .
>  > >  >
>  > >  >  Regards,
>  > >  >  Timm
>  > >  >
>  > >  >
>  >  ---------------------------------------------------------------------
>  > >  >  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  > >  >  For additional commands, e-mail: users-help@wicket.apache.org
>  > >  >
>  > >  >
>  > >
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  > For additional commands, e-mail: users-help@wicket.apache.org
>  >
>  >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setResponsePage(Class c) versus setResponsePage(Page p)

Posted by Johan Compagner <jc...@gmail.com>.
what do you mean redirect does't work?
90% of the time if you do setResponsePage(new Page())
a redirect is done anyway. (for example if you do that in onSubmit)
To go around for example the double post problem if you go back in history
or refresh the page.

johan

On Sat, Mar 29, 2008 at 12:15 AM, James Carman <ja...@carmanconsulting.com>
wrote:

> Oh, and redirect doesn't work with the Page version (at least in my
> tests it didn't).
>
> On Fri, Mar 28, 2008 at 7:13 PM, James Carman
> <ja...@carmanconsulting.com> wrote:
> > If you need to initialize the page instance in some way (by passing
> >  constructor params, for instance), you use the Page version.  The
> >  other version just uses Class.newInstance() to instantiate the page
> >  object.
> >
> >
> >
> >  On Fri, Mar 28, 2008 at 6:44 PM, Timm Helbig <
> timm.helbig@th-hosting.net> wrote:
> >  > Hi,
> >  >
> >  >  I have read several times in the mailing list, that it is bad to use
> >  >  setRespsonsePage(Page p). What is the backdraw compared to
> >  >  setResponsePage(Class c) ?
> >  >
> >  >  In my case a Form Submit redirects to another Page, that needs some
> initial
> >  >  data given through the Constructor, e.g. MyPage(MyInitialData data)
> {} .
> >  >
> >  >  Regards,
> >  >  Timm
> >  >
> >  >
>  ---------------------------------------------------------------------
> >  >  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >  >  For additional commands, e-mail: users-help@wicket.apache.org
> >  >
> >  >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: setResponsePage(Class c) versus setResponsePage(Page p)

Posted by James Carman <ja...@carmanconsulting.com>.
Oh, and redirect doesn't work with the Page version (at least in my
tests it didn't).

On Fri, Mar 28, 2008 at 7:13 PM, James Carman
<ja...@carmanconsulting.com> wrote:
> If you need to initialize the page instance in some way (by passing
>  constructor params, for instance), you use the Page version.  The
>  other version just uses Class.newInstance() to instantiate the page
>  object.
>
>
>
>  On Fri, Mar 28, 2008 at 6:44 PM, Timm Helbig <ti...@th-hosting.net> wrote:
>  > Hi,
>  >
>  >  I have read several times in the mailing list, that it is bad to use
>  >  setRespsonsePage(Page p). What is the backdraw compared to
>  >  setResponsePage(Class c) ?
>  >
>  >  In my case a Form Submit redirects to another Page, that needs some initial
>  >  data given through the Constructor, e.g. MyPage(MyInitialData data) {} .
>  >
>  >  Regards,
>  >  Timm
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  >  For additional commands, e-mail: users-help@wicket.apache.org
>  >
>  >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setResponsePage(Class c) versus setResponsePage(Page p)

Posted by James Carman <ja...@carmanconsulting.com>.
If you need to initialize the page instance in some way (by passing
constructor params, for instance), you use the Page version.  The
other version just uses Class.newInstance() to instantiate the page
object.

On Fri, Mar 28, 2008 at 6:44 PM, Timm Helbig <ti...@th-hosting.net> wrote:
> Hi,
>
>  I have read several times in the mailing list, that it is bad to use
>  setRespsonsePage(Page p). What is the backdraw compared to
>  setResponsePage(Class c) ?
>
>  In my case a Form Submit redirects to another Page, that needs some initial
>  data given through the Constructor, e.g. MyPage(MyInitialData data) {} .
>
>  Regards,
>  Timm
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org