You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by yon10 <ya...@gmail.com> on 2012/11/05 18:11:50 UTC
wicket create a dynamic return class from getHomePage
I am building an web app using wicket 1.5 in my app i need to diside if the
user that is currently login is admin or a regular user and display diffrent
html for each of them.
my code id:
public class HomePage extends WebApplication {
private boolean flag = false;
@Override
protected void init(){do things}
@Override
public Session newSession(Request request, Response response) {
... some calculation ...
return new HomePageWebSession(request);
}
@Override
public Class<? extends WebPage> getHomePage(){
if(flag){
return Admin.class
} else return User.class
}
}
the problem is that getHomepage is activated before newSession and i use
newSession to figure out if the user is Admin or not and init the flag. in
addition i see that the getHomePage is called multiples times before
newSession is been called. way getHomePage is called multiples times and way
getHomePage is called before newSession.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-create-a-dynamic-return-class-from-getHomePage-tp4653631.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: wicket create a dynamic return class from getHomePage
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
You should have a home page for non-authenticated users too.
Once you have a session (authenticated user) requesting '/' will use either
Admin page or User page.
On Mon, Nov 5, 2012 at 7:11 PM, yon10 <ya...@gmail.com> wrote:
> I am building an web app using wicket 1.5 in my app i need to diside if the
> user that is currently login is admin or a regular user and display
> diffrent
> html for each of them.
>
> my code id:
> public class HomePage extends WebApplication {
> private boolean flag = false;
>
> @Override
> protected void init(){do things}
>
> @Override
> public Session newSession(Request request, Response response) {
> ... some calculation ...
> return new HomePageWebSession(request);
> }
>
> @Override
> public Class<? extends WebPage> getHomePage(){
> if(flag){
> return Admin.class
> } else return User.class
> }
> }
>
> the problem is that getHomepage is activated before newSession and i use
> newSession to figure out if the user is Admin or not and init the flag. in
> addition i see that the getHomePage is called multiples times before
> newSession is been called. way getHomePage is called multiples times and
> way
> getHomePage is called before newSession.
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/wicket-create-a-dynamic-return-class-from-getHomePage-tp4653631.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
>
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>