Java Reference
In-Depth Information
private method. You'll then add a new panel that displays the login form and modify
onModuleLoad to display this panel conditionally.
First, rename the current onModuleLoad method to “ loadMainUI” and make it
private. Now add the following imports and methods to TimeEntry.java.
Listing 6-7. Changes to TimeEntry.java
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
public void onModuleLoad() {
logo.setUrl("images/appiriologo.png");
LoginServiceAsync loginService = GWT.create(LoginService.class);
loginService.login(GWT.getHostPageBaseURL(), new
AsyncCallback<LoginInfo>() {
public void onFailure(Throwable error) {
}
public void onSuccess(LoginInfo result) {
loginInfo = result;
if(loginInfo.isLoggedIn()) {
loadMainUI();
} else {
loadLoginUI();
}
}
});
}
private void loadLoginUI() {
VerticalPanel loginPanel = new VerticalPanel();
Anchor loginLink = new Anchor("Sign In");
loginLink.setHref(loginInfo.getLoginUrl());
loginPanel.add(logo);
loginPanel.add(new Label("Please sign-in with your Google Account to
access the Time Entry application."));
loginPanel.add(loginLink);
RootPanel.get("timeentryUI").add(loginPanel);
}
 
Search WWH ::




Custom Search