-
FEATURED COMPONENTS
First time here? Check out the FAQ!
hi all..somebody help me. I want create a tutorial login form using ZK and MVVM..plese help me
Hello smileinheavenn,
Please find below a part of a log in form using mvvm:
Create a window, attach a controller and then you should define a textbox for a user name and password as shown below:
<textbox tabindex="1" value="@bind(vm.user.userName)" height="50px" placeholder="USERNAME"/>
<textbox tabindex="2" value="@bind(vm.user.userPswd)" type="password" height="50px" placeholder="PASSWORD"/>
In the java controller you should define a command that will be associated with the log in button and would have the following code:
@Command("logIn")
public void logIn() {
if (user.getUserName().length() > 0 && user.getUserPswd().length() > 0) {
//If user exists then save session and redirect
UserDaoImpl userDaoImpl = new UserDaoImpl();
User sessionUser = userDaoImpl.userExists(user.getUserName(), user.getUserPswd());
if (null != sessionUser) {
Sessions.getCurrent().setAttribute("s_user", sessionUser);
//Redirect Here
} else {
Clients.showNotification("User does not exist","error",null,"bottom_right",3000, true);
}
} else {
Clients.showNotification("Please set credentials","error",null,"bottom_right",3000, true);
}
}
If you need more info there are some great tutorials and references in the zk site.
Best Regards,
Darksu
Asked: 2015-11-24 02:15:40 +0800
Seen: 79 times
Last updated: Nov 24 '15