Announcement Announcement Module
Collapse
No announcement yet.
post ConnectUrl Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Sorry, I didn't read your post carefully enough

    yeah, postDisconnect is more elegant.

    So the connectionFactory doesn't make sense in this scenario? I guess in my use case I'm most interested in the WebRequest where my session user is and the providerId. These two pieces of information will help me do what I need to do. I can also imagine that you might want to have some kind of preDisconnect interaction. For instance, a tweet saying "John disconnected Twitter from MySite, damn I thought you cared about me".

    Comment


    • #17
      What is it that you would want to do with the ConnectionFactory? You can really only create a Connection with it..doesn't seem useful in a postDisconnect() interceptor. Even then you'd need a ConnectionData object and you don't have enough info post-disconnect to build one of those.

      Comment


      • #18
        Sorry, I must not have been thinking clearly. I was a bit feverish this morning :-)

        Comment


        • #19
          Well, this is a Controller that controls user flow, so whatever is implemented is going to be specific to some kind of flow. As we've implemented it, we control access to a connection status page per provider at GET /connect/{provider}. When creating a new connection or removing an existing connection, we redirect the user back to the connection status page to see the results of the change. This is the flow that has been implemented, nothing more than that.

          If you need a Controller that provides a different flow, for example, one that only exposes a GET /connect handler and POST /connect/{provider} handlers with a completion redirect back to GET /connect, the best thing you can do is implement your own Controller that does what your application needs and nothing more. We've tried to make this easy to do as I said before (even introducing a reusable ConnectSupport class you can delegate to from your custom Controller, and by providing clean APIs you can delegate to). I suspect that would be much cleaner than trying to shoehorn the existing ConnectController flow to fit your application's desired (and distinctly different) flow.

          We can consider supporting alternative flows as well, but the last thing I want to do is turn what we have in ConnectController into some kind of monster because we're trying to do too many things in one class.

          Keith
          Last edited by Keith Donald; Aug 1st, 2011, 06:10 PM.

          Comment


          • #20
            fair enough.

            Comment


            • #21
              Having said that, we can revisit the flow if we think what is currently implemented is not as generally useful as another alternative.

              Specifically, we could consider:

              -> GET /connect
              - Display a master connection status page across all providers. On that page, have a section for each provider. Within each section, have a "Add {Provider}" button that can be clicked to create a new connection in a dialog/popup window e.g. "Add Twitter...". The target for the button could either be POST /connect/{providerId} (to take the user straight to the provider's auth page), or GET /connect/{providerId} to first go to a new connection form where pre-connection settings such as "tweet after connecting", "use Twitter profile photo as my profile picture" can be specified. After auth completes, we'd close the popup and refresh the master connection page, where the new connection can then be managed (e.g. removed).

              If we think such a flow is generally more useful then individual connection status pages per provider, then it's something we can seriously consider. We'll definitely need to do a RC3 release and update each sample, though. To that end, I would really appreciate it if some guidelines/code for the popup handling could be made available for us to integrate.

              Thoughts?

              Keith
              Last edited by Keith Donald; Aug 1st, 2011, 10:59 PM.

              Comment


              • #22
                popup

                Well my code is YUI specific, but the general flow is this.
                1. add a class "social-form" (or whatever) to each form (twitter connect, facebook connect etc)
                2. On page load scan the page for all forms that have this class
                3. add an onsubmit handler to these forms
                4. onsubmit prevent the submit event, create a new window, add the window as target for the form
                5. execute the submit
                6. Once the popup process return, the controller should return a page that detects whether it is an "opener". If so, close the window and do this with the parent: reload, redirect to a page or do nothing. If not, redirect specific page or redirect to home.

                So a simple YUI example could look something like this:
                PHP Code:
                <form action ="/connect/signin" method="POST" class="social-connect">
                [...]
                </
                form>

                var 
                signin= function(event){
                    
                event.preventDefault();
                    var 
                window.open("","scW","status=no,toolbar=no,menubar=no,location=no"); 
                    
                event.currentTarget.setAttribute("target","scW");
                    
                event.currentTarget.submit();
                }

                var 
                sBtn Y.all("form.social-connect");
                if(
                sBtn){
                    
                sBtn.on("submit",signin);

                Comment


                • #23
                  The reason you need to handle the possibility of not being inside a popup is that sometimes this type of code can execute before the YUI library has loaded. If you create a direct onsubmit handler on the form, you won't have this problem but then it should be something along these lines (untested).

                  PHP Code:
                  <form action ="/connect/signin" method="POST" onsubmit="signin(this);"
                  [...] 
                  </
                  form

                  var 
                  signin= function(self){ 
                      var 
                  window.open("","scW","status=no,toolbar=no,menubar=no,location=no");  
                      
                  self.target "scW";
                  }; 

                  Comment


                  • #24
                    I've tried subclassing CustomConnectController as suggested earlier in the thread. So in my jsp I have the following in the connect form:


                    <form method="POST" action="/myapp/connect/twitter">
                    <input type="hidden" value="xxxxx" name="postConnectUrl">
                    <button type="submit">
                    <img src="/myapp/resources/images/twitterLogin.gif">
                    </button>
                    </form>


                    and in the subclassed ConnectController:

                    public class CustomConnectController extends ConnectController {

                    @RequestMapping(value = "/{providerId}",
                    method = RequestMethod.POST)
                    public RedirectView connect(@PathVariable
                    java.lang.String providerId,
                    NativeWebRequest request) {
                    HttpServletRequest nativeReq = request.getNativeRequest(HttpServletRequest.class) ;

                    String postConnectUrl = nativeReq.getParameter("postConnectUrl");
                    nativeReq.getSession().setAttribute("postConnectUr l",postConnectUrl);
                    return super.connect(providerId, request);
                    }



                    in the twitterConnect.jsp I have the following:

                    <%@ page contentType="text/html;charset=UTF-8" language="java" session="true" %>
                    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
                    <c:if test="${postConnectUrl != null}">
                    <c:redirect url="${postConnectUrl}"/>
                    </c:if>
                    <c:redirect url="/<usual url>"/>


                    however although it picks up my postConnectUrl, , it tries to forward to myapp/connect/<postConnectUrl> . Why does it put/connect/ in the middle of the url ?

                    Comment


                    • #25
                      What is the value of your ${postConnectUrl}? If it's not an absolute URL and if it doesn't begin with a "/", then it will be relative to the current request's URL. So, if the current request is /myapp/connect/twitter and you ${postConnectUrl} is "foobar", then it will redirect to /myapp/connect/foobar.

                      Depending on what you're trying to do, you could make sure it has a slash on the beginning, in which case it will (by default) redirect relative to the context path. Or you can set the context parameter on <c:redirect> to be more explicit about what path url is relative to.

                      Comment


                      • #26
                        pefect thanks

                        Comment

                        Working...
                        X