Announcement Announcement Module
Collapse
No announcement yet.
customization of resulting views/controllers in ConnectController? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • customization of resulting views/controllers in ConnectController?

    It looks like ConnectController is hardwired to return to /connect/{provider}Connect or /connect/{provider}Connected. In our application after a user connects we will end up needing to hit a different controller and resulting view.

    ProviderController has a postSignInUrl you can set in your bean config. You think it would be a good idea to have something similar in the ConnectController for when you want to override the default views it redirects to?

    In the meantime, since I'm pretty new to spring and spring mvc, what would be the cleanest approach if after a provider connect operation I want to then hit my own spring controller for some work and then redirect to a different view? Is the easiest to just make a connect/facebookConnected.jsp and in there just do a <jsp:forward ... > That seems like a pretty ugly solution though so there is probably a much cleaner way that I'm overlooking?

  • #2
    If you'd like to go somewhere else after a connect/disconnection, you can subclass ConnectController and override the connectView() and connectedView() methods to return the view name you'd like to go to. This could even include a "redirect:" directive to redirect to a URL that your own controller handles.

    Comment


    • #3
      Originally posted by habuma View Post
      If you'd like to go somewhere else after a connect/disconnection, you can subclass ConnectController and override the connectView() and connectedView() methods to return the view name you'd like to go to. This could even include a "redirect:" directive to redirect to a URL that your own controller handles.
      Hmmm I only see connectView (not connectedView) 1.0.0.RC2. And connectView is also called from connectionStatus. I could still subclass and get things to work. Might be nice though if all three of those calls to connectView could be customizable as properties. (If they're null, they'll just default to how it is now.)

      Here's what the source code I have looks like:

      Code:
      @RequestMapping(value="/", method=RequestMethod.GET)
      	public String connectionStatus(NativeWebRequest request, Model model) {
      		setNoCache(request);
      		Map<String, List<Connection<?>>> connections = connectionRepository.findAllConnections();
      		model.addAttribute("providerIds", connectionFactoryLocator.registeredProviderIds());		
      		model.addAttribute("connectionMap", connections);
      		return connectView("status");
      	}
      
      	/**
      	 * Render the status of the connections to the service provider to the user as HTML in their web browser.
      	 */
      	@RequestMapping(value="/{providerId}", method=RequestMethod.GET)
      	public String connectionStatus(@PathVariable String providerId, NativeWebRequest request, Model model) {
      		processFlash(request, model);
      		List<Connection<?>> connections = connectionRepository.findConnections(providerId);
      		setNoCache(request);
      		if (connections.isEmpty()) {
      			return connectView(providerId + "Connect"); 
      		} else {
      			model.addAttribute("connections", connections);
      			return connectView(providerId + "Connected");			
      		}
      	}

      Comment

      Working...
      X