On Saturday, June 4, 2011 11:47:08 PM UTC+2, Jeff Schnitzer wrote:
>
> I'm trying to implement a simple pattern that is *very* common in the
> world of "normal" webapps:
>
> 1) Most of my application requires authentication in order to access.
> 2) I allow deep links to protected content.
> 3) When visiting a deep link, you are given a login page - after
> logging in, you get the content.
>
> I have a single-page GWT app that uses Places. I've spent a lot of
> time on this issue, and I *almost* have it working - but it's not
> elegant and there are still broken edge cases. If you want to
> experience it firsthand, visit http://www.similarity.com/#matches:
>
> The specific issues with the Places system are:
>
> * The default place is different in authenticated mode vs anonymous
> mode. When you are anonymous, your default place is the "hello,
> stranger" place but when you're logged in, the default place is "all
> about your account". Since I can't reset the default place in the
> PlaceHistoryHandler, I need to swap out the instance when I switch
> modes.
>
Or maybe you could have a single place and have the ActivityMappers (or
whatever PlaceChangeHandler if you're not using Activities) react
differently whether the user is authenticated or not.
* The PlaceController has no way to reset the current place. When an
> anonymous user tries to go to the #matches: link, the place is set to
> MatchesPlace (which my special handler translates into a "you must log
> in first" message). When the user logs in, I force another
> handleCurrentHistory(), but it doesn't actually do anything - because
> the PlaceController is already at MatchesPlace. I'll have to swap out
> the PlaceController instance when I switch modes.
>
Authentication is (should be) orthogonal to navigation. When the user
authenticates, you should dispatch a LoginEvent (or similar) on the event
bus and have the activities (or whatever) refresh their content ("restart").
> And now a little rant:
>
> All in all, this seems ludicrously difficult for something I could
> have done with dozen lines of code if I wasn't trying to use the
> standard GWT tools. I feel like I've wasted a lot of time learning
> the system, and what I've ultimately learned is that I would be better
> off building it from scratch.
>
> Am I the only one that thinks the Places system is WAY
> over-engineered, yet not all that useful?
>
Before it existed, I built something that was very similar, so no, I don't
think it's over-engineered (quite the contrary actually). BTW, it's just a
tool, you're free to use it or not. Nobody said it's a "one size fit all",
there are probably use cases where it's not a good fit (or not the best
fit).
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/TWxxZjNhTVF5aWNK.
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.