Open GoogleCodeExporter opened 9 years ago
Hi,
You can remove it if you want:
windowPanel.getHeader().clear();
or you can can call showLoginForm() in a loop until login is successful.
A simple login showLoginForm() is below, the close button is like Cancel button.
Let me know if that helps.
Kind Regards,
George.
private void showLoginForm() {
final TextBox username = new TextBox();
final PasswordTextBox passwd = new PasswordTextBox();
final MessageBox prompt = new MessageBox(MessageBoxType.PASSWORD,
"Login Form") {
@Override
public void onClose(boolean result) {
hide();
if (result) {
InfoPanel.show("Login Form", "Form submitted!");
} else {
InfoPanel.show("Login Form", "You clicked 'Cancel'.");
}
}
};
prompt.setAnimationEnabled(false);
final int width = Math.max(Window.getClientWidth() / 3, 256);
prompt.setWidth(width + "px");
// Create a panel to hold all of the form widgets
final LayoutPanel panel = new LayoutPanel(new BoxLayout(
Orientation.VERTICAL));
panel.setPadding(0);
panel.add(new HTML("User name:"), new BoxLayoutData(FillStyle.HORIZONTAL));
panel.add(username, new BoxLayoutData(FillStyle.HORIZONTAL));
panel.add(new HTML("Password:"), new BoxLayoutData(FillStyle.HORIZONTAL));
panel.add(passwd, new BoxLayoutData(FillStyle.HORIZONTAL));
// Add a 'submit' button.
Button buttonSubmit = new Button("Submit");
buttonSubmit.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
REMOTE_CLOUDFILES_SERVICE.login(username.getText(), passwd.getText(),
new AsyncCallback<Boolean>() {
public void onFailure(Throwable caught) {
GWT.log(caught.getMessage(), caught);
InfoPanel.show(InfoPanelType.HUMANIZED_MESSAGE, "Login",
"Authetication failed with message: "
+ caught.getLocalizedMessage());
}
public void onSuccess(Boolean result) {
if (result != null && result) {
startup();
} else {
InfoPanel.show(InfoPanelType.HUMANIZED_MESSAGE, "Login",
"Authetication failed!");
}
}
});
prompt.onClose(true);
}
});
prompt.getButtonPanel().add(buttonSubmit);
// Add a 'cancel' button.
Button buttonCancel = new Button("Cancel");
buttonCancel.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
prompt.onClose(false);
}
});
prompt.getButtonPanel().add(buttonCancel);
prompt.setWidget(panel);
prompt.showModal();
if (prompt.getOffsetWidth() < width) {
prompt.setWidth(width + "px");
}
DeferredCommand.addCommand(new Command() {
public void execute() {
username.setFocus(true);
}
});
}
Original comment by georgopo...@gmail.com
on 10 Nov 2009 at 9:07
Original issue reported on code.google.com by
stefanre...@gmail.com
on 10 Nov 2009 at 8:21