Login form in zk using MVVM

asked 2015-11-24 02:15:40 +0800

smileinheavenn gravatar image smileinheavenn

hi all..somebody help me. I want create a tutorial login form using ZK and MVVM..plese help me

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-11-24 10:09:55 +0800

Darksu gravatar image Darksu
1991 1 4

Hello smileinheavenn,

Please find below a part of a log in form using mvvm:

  • Zul:

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"/>
  • Java Controller:

In the java controller you should define a command that will be associated with the log in button and would have the following code:

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);

  • There are some key parts that you should pay attention such as the domain model, the persistence layer, and the way you use the session in order to store the logged in user.

If you need more info there are some great tutorials and references in the zk site.

Best Regards,


link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2015-11-24 02:15:40 +0800

Seen: 52 times

Last updated: Nov 24 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More