Noob question: Link to Page that only Redirects?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Noob question: Link to Page that only Redirects?

syg6
I have a Page class, HomePage.java.

In that class I have a Link:

add(new BookmarkablePageLink<MyLinkPage>("myLink",
            MyLinkPage.class));

MyLinkPage just does some checking in the database and either redirects to QuestionPage or ErrorPage. It doesn't need to have any markup.

So my question is: in HomePage can I add a Link to something that is *not* a Page? That simply calls my code and redirects?

Been looking on the forum, haven't seen anyone talking about it ...

Thanks,
Bob

Reply | Threaded
Open this post in threaded view
|

Re: Noob question: Link to Page that only Redirects?

flavius

On your MyLinkPage you can just setResponsePage...

So

if (gotoQuestionPage)
  setResponsePage(QuestionPage.class);
else
  setResponsePage(ErrorPage.class);

Is that what you're after?
Reply | Threaded
Open this post in threaded view
|

Re: Noob question: Link to Page that only Redirects?

syg6
That's pretty much what I was going to do, thanks for the code snippet.

My question was more about the design or philosophy of Wicket. Namely, should this type of logic be in a Page class? The MyLinkPage doesn't actually exist as an html page. It's just a chunk of logic that redirects to one Page or another.

Is there anywhere else I could stick it and then link to it with a Link? Perhaps a Panel or some other Component?

On the other hand, if this is normal, well then I'll just leave it in the Page.

Thanks again
Bob