0

set fucus textbox mvvm

asked 2012-11-02 07:02:50 +0800

longdv1208 gravatar image longdv1208
98 4

I want use mvc

public class FmisLogin extends SelectorComposer<Window> {

	@SuppressWarnings("unused")
	private final static Logger logger = Logger.getLogger(FmisLogin.class);
	private static final long serialVersionUID = -71422545405325060L;

	// @Wire
	// private Label lbl_ServerTime;
	@Wire
	private Textbox txtbox_Username, txtbox_Password;

	public FmisLogin() {
		super();
	}

	@Override
	public void doAfterCompose(Window comp) throws Exception {
		super.doAfterCompose(comp);
		this.txtbox_Username.setValue("admin");
		this.txtbox_Password.setValue("admin");
		this.txtbox_Username.focus();
	}

	@Listen("onClick=#btnReset")
	public void onReset(Event event) {
		this.txtbox_Username.setValue("");
		this.txtbox_Password.setValue("");
		this.txtbox_Username.focus();
	}

	@Listen("onClick=#btnClosed")
	public void onClosed() throws IOException {
		Executions.sendRedirect("/j_spring_logout");
	}


}

change to mvvm set fucus txtbox_Username

public class LoginViewModel {

	private String username = "admin";
	private String password = "admin";

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Command
	public void reset() {
		setUsername("");
		setPassword("");
	}

	@Command
	public void onClosed() {
		Executions.sendRedirect("/j_spring_logout");
	}
}

delete flag offensive retag edit
Be the first one to reply this discussion!
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

Follow

RSS

Stats

Asked: 2012-11-02 07:02:50 +0800

Seen: 61 times

Last updated: Nov 02 '12

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