form = new DynamicForm();
form.setFields(username,pass);
form.setAutoFocus(true);
fillTextsWithCookie(username,pass);
final CheckboxItem ch_remember = new CheckboxItem();
ch_remember.setTitle("Remember me");
ch_remember.setValue(true);
DynamicForm remember_form = new DynamicForm();
remember_form.setFields(ch_remember);
final HTMLFlow message = new HTMLFlow();
//message.setVisible(true);
IButton loginButton = new IButton("Login");
//loginButton.setSelected(true);
//loginButton.setLeft(300);
loginButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final String username = getFieldValue("username").toLowerCase();
final String pass = getFieldValue("pass");
if(isAnyEmptyField(username,pass))
message.setContents("Please do not leave any field empty!");
else
systemcall.login(username,pass, new AsyncCallback<Boolean>(){
public void onSuccess(Boolean success)
{
if(!success)
{
message.setContents("Failed to login!");
}else
{
if(ch_remember.getValueAsBoolean())
setLastLoginName(username, pass);
else{
if(username.equals(getLastUserName()) && pass.equals(getLastPassword())){
removeLastLoginName();
}
}
window.destroy();
}
}
public void onFailure(Throwable t)
{
Log.debug("Login->onFailure " + t);
}
});
}
});
IButton createButton = new IButton("Create Account");
createButton.setLeft(300);
createButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final String username = getFieldValue("username").toLowerCase();
final String pass = getFieldValue("pass");
if(isAnyEmptyField(username,pass))
message.setContents("Please do not leave any field empty!");
else
systemcall.createuser(username.toLowerCase(), pass, new AsyncCallback<Boolean>(){
public void onSuccess(Boolean success)
{
Log.debug("Success : " + success);
if(!success)
{
message.setContents("This id already exist. Try another one!");
}else
{
systemcall.login(username.toLowerCase(), pass, new AsyncCallback<Boolean>()
{
public void onSuccess(Boolean success)
{
if(!success)
{
message.setContents("Failed to login!");
}else
{
if(ch_remember.getValueAsBoolean())
setLastLoginName(username, pass);
window.destroy();
}
}
public void onFailure(Throwable t)