In Firefox when accessing the sessionID cookie via a
FormHandler.onSubmitComplet(FormSubmitCompleteEvent event) { } it (GWT
1.5) is wrapping the sessionID with <pre></pre> tags.
It is not doing this in IE.
Code is below, any ideas how to resolve this? Thanks,
public class Login implements EntryPoint {
private Button clickMeButton;
final boolean maintenanceMode = false;
VerticalPanel main = new VerticalPanel();
public void onModuleLoad() {
RootPanel.get("main").add(main);
clickMeButton = new Button();
main.add(clickMeButton);
clickMeButton.setText("Click me!");
clickMeButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
Window.alert("Hello, GWT World!");
}
});
FormPanel form = FormPanel.wrap(Document.get().getElementById
("loginForm"),true);
final Button submit = Button.wrap(Document.get().getElementById
("submit"));
form.addFormHandler(new FormHandler() {
public void onSubmit(FormSubmitEvent event) {
submit.setEnabled(false);
}
public void onSubmitComplete(FormSubmitCompleteEvent event) {
submit.setEnabled(true);
String sessionID = (String) event.getResults();
if(!sessionID.contains("failed")) {
final long DURATION = 1000 * 30;
Date expires = new Date(System.currentTimeMillis() +
DURATION);
Cookies.setCookie("un", DOM.getElementById("un").getAttribute
("value"), expires, null, "/", false);
Cookies.setCookie("sid", sessionID, expires, null, "/",
false);
DOM.setStyleAttribute(DOM.getElementById("login"),
"visibility", "hidden");
DOM.setStyleAttribute(DOM.getElementById("loginError"),
"visibility", "hidden");
DOM.setStyleAttribute(DOM.getElementById("newUserButton"),
"visibility", "hidden");
DOM.setStyleAttribute(DOM.getElementById("main"),
"visibility", "visible");
//setMainUI();
} else if (DOM.getStyleAttribute(DOM.getElementById
("newUser"), "visibility").equals("hidden")) {
RootPanel.get("loginError").clear();
RootPanel.get("loginError").add(new ErrorMsg("Incorrect
Username / Password Combination"));
DOM.setStyleAttribute(DOM.getElementById("loginError"),
"visibility", "visible");
DOM.setStyleAttribute(DOM.getElementById("login"),
"visibility", "visible");
DOM.setStyleAttribute(DOM.getElementById("main"),
"visibility", "hidden");
}
}});
checkIfSessionIsStillLegal();
}
private void checkIfSessionIsStillLegal() {
if(Cookies.getCookie("sid")!=null)
checkRemoteSession(Cookies.getCookie("sid"));
else if(maintenanceMode)
setMainUI();
else
displayLoginBox();
}
public void setMainUI() {
if(RootPanel.get("main").getWidgetCount()>0)
RootPanel.get("main").remove(0);
RootPanel.get("main").add(main);
DOM.setStyleAttribute(DOM.getElementById("login"), "visibility",
"hidden");
DOM.setStyleAttribute(DOM.getElementById("main"), "visibility",
"visible");
}
public void displayLoginBox() {
DOM.setStyleAttribute(DOM.getElementById("login"), "visibility",
"visible");
DOM.setStyleAttribute(DOM.getElementById("main"), "visibility",
"hidden");
}
public void onHistoryChanged(String historyToken) {
//setMainUI();
}
public static void checkRemoteSession(String sid) {
LoginServiceAsync myService = (LoginServiceAsync) GWT.create
(LoginService.class);
ServiceDefTarget endpoint = (ServiceDefTarget) myService;
String moduleRelativeURL = GWT.getModuleBaseURL() + "db";
endpoint.setServiceEntryPoint(moduleRelativeURL);
AsyncCallback callback = new AsyncCallback() {
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
caught.printStackTrace();
}
public void onSuccess(Object result) {
String message = (String) result;
Window.alert("checkRemoteSession message=" + message);
if(!message.equals("failed")) {
DOM.setStyleAttribute(DOM.getElementById("login"),
"visibility", "hidden");
DOM.setStyleAttribute(DOM.getElementById("main"),
"visibility", "visible");
} else {
DOM.setStyleAttribute(DOM.getElementById("login"),
"visibility", "visible");
DOM.setStyleAttribute(DOM.getElementById("main"),
"visibility", "hidden");
}
}};
myService.checkSID(sid, callback);
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---