Monday, August 30, 2010

Re: problems with auto-complete form login

On 30 août, 07:45, Magnus <> wrote:
> Hi,
> I implemented a login form suitable for auto-complete by the browser
> nearly exactly as described here:

...which violates rule #3: do not move the form around or the browser
will treat it the same as a dynamically generated form and won't auto-
fill it (well, it really depends on which browser, and probably which
browser version).
All you're "allowed" to do with the form is to show and hide it and
change its style.
(but believe me, you'd rather externalize the login process from your
app, just like Google apps –as you're using GMail, you should
understand what I mean–, it makes things so much simpler!)

> Unfortunately, I have problems with it:
> 1. The password field is not filled in.
> When I login for the first time the browser (FF) asks me to remember
> the form fields. I can verify in the browsers settings that the
> username and password is stored in the browser.
> However, when I login again, only the username field is autofilled.
> The password field is empty.

See above, the problem is moving the FormPanel around (adding it to a
VerticalPanel in this case).

> 2. I cannot repeat the login.
> When I login, logout and then try to login again, the form cannot be
> created. The call to Document.get().getElementById(LOGINFORM_ID);
> returns null.

First, because the form has already been wrapped, you shouldn't try to
wrap it again; consider your FormPanel as a singleton, and always
reuse it (as a rule of thumb, make all your views singletons if you
can; working with the DOM is probably what degrades your app's
performances the most, so try to not do it more than necessary).
In your case, getElementById probably returns null because you removed
the FormPanel from the document instead of just hiding/showing it.

But let me reiterate: your life will be easier if you externalize the
login process from your app.
When the app loads, it knows if the user is authenticated (in case you
authorize unauthenticated access, otherwise the app wouldn't even be
loaded as the "authentication gatekeeper" wouldn't let the user in
without first authenticating) and who she is; and the user's identity
cannot change through the lifetime of the app (signing out will unload
the app, re-signing in will load it again), which means you can keep
data "cached". Integrating the login process in your app means
dispatching login/logout events and handling them to clear cached
data, which can really become very painful.
Believe me on this, I built two apps this way before I realize the
obvious (well, I already knew it before making the second one, but it
had to work the same as the first :-( )

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment