You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by vov <vo...@mail.ru> on 2013/02/14 14:17:49 UTC
Redirect to the HomePage on newSession
Is it possible to redirect user to the HomePage when new session is created?
@Override
public Session newSession(Request request, Response response)
{
//RequestCycle.get().setResponsePage(getHomePage());
//or
//RequestCycle.get().replaceAllRequestHandlers(new
RenderPageRequestHandler(new //PageProvider(getHomePage())));
// do not work
}
The main idea is always show HomePage when user logged in to the application
and not take into account the URL which was printed to the address line
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Redirect-to-the-HomePage-on-newSession-tp4656365.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Redirect to the HomePage on newSession
Posted by Paul Bors <pa...@bors.ws>.
You can always throw a RestartResponseAtInterceptPageException(Page) and
let Wicket do the redirect for you.
~ Thank you,
Paul Bors
On Fri, Feb 15, 2013 at 6:08 AM, vov <vo...@mail.ru> wrote:
> Found good solution:
>
> @Override
> protected void init()
> {
> getRootRequestMapperAsCompound().add(new
> LoginHomePageMapper(getHomePage()));
> }
>
> private static class LoginHomePageMapper extends MountedMapper
> {
> public LoginHomePageMapper(Class<? extends IRequestablePage> pageClass)
> {
> super("/", pageClass);
> }
>
> @Override
> public int getCompatibilityScore(Request request)
> {
> MySession session = (MySession) Session.get();
> if (session.isNewCreated())
> {
> session.setNewCreated(false);
> return Integer.MAX_VALUE;
> }
>
> return Integer.MIN_VALUE;
> }
>
> @Override
> protected UrlInfo parseRequest(Request request)
> {
> return new UrlInfo(null, getContext().getHomePageClass(),
> newPageParameters());
> }
> }
>
> Thank you all for your efforts
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Redirect-to-the-HomePage-on-newSession-tp4656365p4656395.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Redirect to the HomePage on newSession
Posted by vov <vo...@mail.ru>.
Found good solution:
@Override
protected void init()
{
getRootRequestMapperAsCompound().add(new
LoginHomePageMapper(getHomePage()));
}
private static class LoginHomePageMapper extends MountedMapper
{
public LoginHomePageMapper(Class<? extends IRequestablePage> pageClass)
{
super("/", pageClass);
}
@Override
public int getCompatibilityScore(Request request)
{
MySession session = (MySession) Session.get();
if (session.isNewCreated())
{
session.setNewCreated(false);
return Integer.MAX_VALUE;
}
return Integer.MIN_VALUE;
}
@Override
protected UrlInfo parseRequest(Request request)
{
return new UrlInfo(null, getContext().getHomePageClass(),
newPageParameters());
}
}
Thank you all for your efforts
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Redirect-to-the-HomePage-on-newSession-tp4656365p4656395.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Redirect to the HomePage on newSession
Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi,
1- Add some flag to the WIcketSession to mark first time user enters the
application (e.g entered = false).
2- Assuming you have a base page for all pages... On base page constructor
you check entered == false. If so you set flag to true and redirect to
homepage.
RequestCycle.get().setResponsePage(getHomePage());
This way every page will redirect to home first time user is authenticated.
On Fri, Feb 15, 2013 at 9:22 AM, vov <vo...@mail.ru> wrote:
> Hi Stefan,
>
> It's a good solution but I have external authentication system and only
> thing that I know - is creation of the new session:(
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Redirect-to-the-HomePage-on-newSession-tp4656365p4656384.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Regards - Ernesto Reinaldo Barreiro
Antilia Soft
http://antiliasoft.com/ <http://antiliasoft.com/antilia>
Re: Redirect to the HomePage on newSession
Posted by vov <vo...@mail.ru>.
Hi Stefan,
It's a good solution but I have external authentication system and only
thing that I know - is creation of the new session:(
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Redirect-to-the-HomePage-on-newSession-tp4656365p4656384.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Redirect to the HomePage on newSession
Posted by Stefan Renz <s....@efonds.com>.
vov wrote:
> Is it possible to redirect user to the HomePage when new session is created?
>
> @Override
> public Session newSession(Request request, Response response)
> {
>
> //RequestCycle.get().setResponsePage(getHomePage());
> //or
> //RequestCycle.get().replaceAllRequestHandlers(new
> RenderPageRequestHandler(new //PageProvider(getHomePage())));
> // do not work
> }
>
> The main idea is always show HomePage when user logged in to the application
> and not take into account the URL which was printed to the address line
Hi,
how about having a LoginPage/Panel that doesn't
continueToOriginalDestination()? Instead, it could setResponsePage(
Application.get().getHomePage() ) after successful authentication.
I think that should achieve what you want.
Bye
Stefan
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Redirect-to-the-HomePage-on-newSession-tp4656365.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
--
im Auftrag der eFonds Solutions AG, +49-89-579494-3417
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Redirect to the HomePage on newSession
Posted by vov <vo...@mail.ru>.
Hi,
unfortunately it does not help. Use session listener roughly the same with
using newSession method.
I found one solution but looks like workaround without a real needed.
1) throw CustomExceprion on the onCreated method of the ISessionListener.
2) Replace DefaultExceptionMapperProvider with CustomExceptionMapperProvider
@Override
public IExceptionMapper get()
{
return new IExceptionMapper()
{
@Override
public IRequestHandler map(Exception e)
{
if (e instanceof CustomExceprion )
{
return new RenderPageRequestHandler(new
PageProvider(Application.get().getHomePage()));
}
}
};
}
Does anybody know better solution?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Redirect-to-the-HomePage-on-newSession-tp4656365p4656382.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Redirect to the HomePage on newSession
Posted by Andrea Del Bene <an...@gmail.com>.
Hi,
try using session listener interface ISessionListener. This entity
defines method onCreated called after a new session ahas been created.
To register a custom session listener use the following code in
application class:
public void init(){
super.init();
ISessionListener myListener;
//listener initialization...
getSessionListeners().add(myListener);
}
> Is it possible to redirect user to the HomePage when new session is created?
>
> @Override
> public Session newSession(Request request, Response response)
> {
>
> //RequestCycle.get().setResponsePage(getHomePage());
> //or
> //RequestCycle.get().replaceAllRequestHandlers(new
> RenderPageRequestHandler(new //PageProvider(getHomePage())));
> // do not work
> }
>
> The main idea is always show HomePage when user logged in to the application
> and not take into account the URL which was printed to the address line
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Redirect-to-the-HomePage-on-newSession-tp4656365.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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