Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Friday, December 30, 2011

Redirecting to a URL from a action listener in ADF 11g

Very recently I was working on implementing OaAuth flow a typical standard these days to authenticate against various social media sties like facebook, twitter etc. using my ADF app. Typically, the first step in OaAuth flow is to call to a url passing some sort of consumer or app id which then in turns after authentication invokes a callback url from your application to do the next step.

As a result, I needed a way to invoke the url from adf command button actionListener after constructing the url containing user supplied consumerKey. So, here is how you can invoke the url after that:



    FacesContext fc = FacesContext.getCurrentInstance();
    String callbackUrl = "https://www.facebook.com/dialog/oauth?client_id=" + fbClientId.getValue().toString() + "&redirect_uri=http://mycallbackURL&scope=publish_stream";
    try
    {
      fc.getExternalContext().redirect(callbackUrl);
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }

So this is written in the actionListener and fbClientId is bound to a inputText on UI.


3 comments:

Buy domain names said...

Thanks for the post..It was nice being here..

Anonymous said...

I am totally delighted with incredibly blog greatly that saved me! God bless you “Progress is impossible without change, and those who cannot change their minds cannot change anything.” - George Bernard Shaw

Anonymous said...

Hi,

A very nice post .
It saved a lot of my time.

Thanks for it.