column.addMember(hr);
HStack row = new HStack();
row.setMembersMargin(5);
row.setAlign(VerticalAlignment.CENTER);
IButton okButton = new EnhancedIButton(MSG.common_button_ok());
okButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
//F5 refresh check? If they've reloaded the form for some reason then bail.
boolean credentialsEmpty = ((user == null) || (user.trim().isEmpty()) || (password == null) || (password
.trim().isEmpty()));
//check for session timeout
if (UserSessionManager.isLoggedOut() || (credentialsEmpty)) {
resetLogin();
return;
}
//validation
if (inputForm.validate()) {
Log.trace("Successfully validated all data for user registration.");
//populate form
if (first.getValue() != null)
inputForm.setValue(FIRST, String.valueOf(first.getValue()));
if (last.getValue() != null)
inputForm.setValue(LAST, String.valueOf(last.getValue()));
inputForm.setValue(USERNAME, String.valueOf(username.getValue()));
if (email.getValue() != null)
inputForm.setValue(EMAIL, String.valueOf(email.getValue()));
if (phone.getValue() != null)
inputForm.setValue(PHONE, String.valueOf(phone.getValue()));
if (department.getValue() != null)
inputForm.setValue(DEPARTMENT, String.valueOf(department.getValue()));
inputForm.setValue(SESSIONID, sessionId);
inputForm.setValue(PASSWORD, password);
registerLdapUser(inputForm, callback);
}
}
});
row.addMember(okButton);
//prepopulate form from user details returned.
Subject subject = UserSessionManager.getSessionSubject();
first.setValue(subject.getFirstName());
last.setValue(subject.getLastName());
email.setValue(subject.getEmailAddress());
phone.setValue(subject.getPhoneNumber());
department.setValue(subject.getDepartment());
IButton resetButton = new EnhancedIButton(MSG.common_button_reset());
resetButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
//F5 refresh check? If they've reloaded the form for some reason then bail.
boolean credentialsEmpty = ((user == null) || (user.trim().isEmpty()) || (password == null) || (password
.trim().isEmpty()));
if (UserSessionManager.isLoggedOut() || credentialsEmpty) {
resetLogin();
return;
}
//clear out all validation messages.
String empty = " ";
first.setValue(empty);
last.setValue(empty);
email.setValue("test@test.com");
inputForm.validate();
first.clearValue();
last.clearValue();
email.clearValue();
phone.clearValue();
department.clearValue();
}
});
row.addMember(resetButton);
IButton cancelButton = new EnhancedIButton(MSG.common_button_cancel());
cancelButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
UserSessionManager.logout();
resetLogin();
}
});