ets-berkeley-edu/calcentral — pull request #9 by ctweney (2012-09-06 00:30:34+00:00)
Title: CLC-97 Get user data in every JSP

Trickier than I expected given some Spring complexities, but the final solution is neat and relatively clean. We define UserJSONTag as a JSP tag. It outputs the User bean of the currently logged in user as JSON. This tag is used in footer.tag, used by every JSP. So every JSP now has calcentral.User.Data defined and ready to go before script.js even loads.

Explanation of a couple of framework oddities:

1) The springSecurityFilterChain now maps every URL so that the remote user data will be available even on unsecured pages like / and /colleges-and-schools.

2) Spring autowiring doesn't work in JSP tag classes, so we have to use the webapp context getter to get the UserService.

From a UX dev's perspective, the calcentral.Api.User.getCurrentUser function in script.js no longer does an ajax request. If you need an ajax request to get the up-to-date data, use calcentral.Api.User.refreshCurrentUser instead.