package com.smartgwt.sample.client;

import com.smartgwt.client.util.BooleanCallback;
import com.smartgwt.client.util.SC;


public class LoginPage extends LogonPage {

	private BooleanCallback callback;

	private boolean callLogin = true;

	public LoginPage(BooleanCallback callback) {
		this(true, callback);
	}

	public LoginPage(boolean callLogin, BooleanCallback booleanCallback) {
		super();
		
		//not used
		this.rememberMe.hide();
		
		this.callLogin = callLogin;
		this.callback = booleanCallback;

		logonButton
				.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {

					@Override
					public void onClick(
							com.smartgwt.client.widgets.events.ClickEvent event) {
	
							SC.say("Login Button has been clicked");
					}
				});
		this.forgotPassword.setTarget("javascript");
		this.forgotPassword.setCellStyle("basicLink");
		
	}


	public String getUsername() {
		return username.getValueAsString();
	}

	public String getPassword() {
		return password.getValueAsString();
	}


	@Override
	protected String getProductName() {
		return "Welcome";
	}

	@Override
	public void enableDisableLoginButton() {
		if (username.getValue() != null && password.getValue() != null
				&& username.getValueAsString().trim().length() > 7
				&& password.getValueAsString().length() > 7) {
			logonButton.enable();
		} else {
			logonButton.disable();
		}
	}

}
