I tried to implement a solution that would trigger the browsers
function to ask for "remember this username and password" by the built
in AUTOCOMPLETE feature. I found the post below but only got it
working in FireFox. Does anyone have a different solution that works
in most browsers?
------------
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/fe4a68568a012642/a2503188b41f97a0?lnk=gst&q=autocomplete+on+password#a2503188b41f97a0
------------
I reduced the number of JSNI calls to a single line of code but I
still only got this working in FireFox.
Here is my implementation:
The form in the HTML-file:
<!-- hidden login form that triggers password autocomplete. See code
in LoginDialog.java -->
<div id="hiddenLoginDiv" style="display:none" >
<form id="hiddenLoginForm" method="post" action="dummy.html"
onsubmit="javascript:return false;">
<input id="username" name="username" type="text"
size="20"
maxlength="100" />
<input id="password" name="password" type="password"
size="20"
maxlength="100" />
<input id="hiddenLoginFormSubmitButton" type="submit" />
</form>
</div>
And the login code called from my login dialog:
/*
* from:
*
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/fe4a68568a012642/a2503188b41f97a0?lnk=gst&q=autocomplete+on+password#a2503188b41f97a0
* in my entry-point I simply read those values and set them into my
gwt-text and gwt-password fields.
* if the html values are empty, my gwt-fields will also be empty
(this is always the case when the user
* enters the site for the first time).
* when the user then clicks my login-button:
* I copy the values from my gwt-fields back to the html-fields in
the hidden form
* then I call click on the hidden form's submit button (which will
NOT submit the form, see onsubmit()) this triggers the browsers
passwordmanager
* then I proceed with my own login-routine on the server
* NOTES:
* I am not sure, that this will work in all browsers password
managers -
* I think some browsers require the form to really be submitted
anyway: it works well in firefox 3
*
http://code.google.com/docreader/#p=google-web-toolkit-incubator&s=go...
* to trigger the form submit:
* will trigger the submit action of the dummy login form for
password managers
* the form will not be submitted, because the onSubmit function will
always return false.
* note: calling form.submit() instead of calling button.click() will
not call the onSubmit function
* but submit the form immediately.
*
*/
private String getUsernameFromHTML() {
return
DOM.getElementById("username").getPropertyString("value");
}
private String getPasswordFromHTML() {
return
DOM.getElementById("password").getPropertyString("value");
}
private void submitHiddenLoginForm(String usernameValue, String
passwordValue) {
DOM.getElementById("username").setPropertyString("value",
usernameValue);
DOM.getElementById("password").setPropertyString("value",
passwordValue);
click(DOM.getElementById("hiddenLoginFormSubmitButton"));
}
private static native void click(Element submitButton)
/*-{
submitButton.click();
}-*/;
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---