0

I'm developing an application using ZK. I have implemented user credential where if the user tried to access index page before login then the app will redirect it to the login page. The login process is working smoothly. The question is, after i have logged in then when I access the login page (ex: login.zul) then the login box still there. How can I redirect it to the default page?

Thanks.

Mohammad Irfan
  • 101
  • 3
  • 12
  • 1. Please keep in mind, that redirects are not ajax, and should be avoided in zk. 2. Do you use spring? Cos zk+spring can make login things easy to you. [Link](http://books.zkoss.org/wiki/ZK%20Spring%20Essentials/Working%20with%20ZK%20Spring) – Nabil A. Oct 07 '13 at 07:41
  • I'd like to silently redirect to the index page if the user has logged in and not to display the login page anymore. I'm not using spring. Only pure zk for the web interface. – Mohammad Irfan Oct 07 '13 at 23:25

1 Answers1

1

Just check if user is loggedin at the time of creation of a Component.
In my example I assume you have a Window.
For MVVM
login.zul

<window ... onCreate="@command('checkLogin')>
...

java

@Command
public void checkLogin(){
if(loggedIn) Executions.sendRedirect("/zul/home.zul");
}

For MVC

login.zul

<window ... id="myLoginWin">
...

java

@Listen("onCreate = #myLoginWin")
public void checkLogin(){
if(loggedIn) Executions.sendRedirect("/zul/home.zul");
}
Nabil A.
  • 3,270
  • 17
  • 29