Adopt a School

Disclaimer

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

Tuesday, March 20, 2012

ADF Library to ViewController or to Model ?

Very recently, I got into the conversation when a friend got an external ADF library which had BC4J components and he wanted to use it to create a UI page.

As the library contained BC4J components or you can say an ApplicationModule so the first thought came was  to add the library to the model project and expecting the AM bundled in the library to show up in Data Controls. And when it was tried this way the AM did not show up in the Data controls. Refreshing, rebuilding the project or even restart did not help.

So, trying to dig further when we opened the model project properties and went to the business components import we could see the EOs,VOs and AM from the ADF library.

After a while, when the library was added to the ViewController project and the ApplicationModule immediately showed up in the data controls. So, what was actually happening here?


Well, that's actually how it should have been done. As a thumb rule, if you want to build UI based on the ADF library jar provided by third party then it should be a dependency of UI project not the model project. However, if you want to extend your BC4J components based on the provided components in the adf library then you should add it to the model project.

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.


Thursday, August 4, 2011

Conclusion on Chris Muir's ADF Task Flow Behavior in 11g

Chris Muir wrote an excellent series on the behavior of adf task flows in conjunction with the transaction control options and am connection. You can find all from the last post available here 

For little impatient people who may not have enough time to go through all the 4 blog posts may read the key points here:


1. A Bounded Task flow knows to which AM to connect and establish which db connection only via page definition file bindings. So, a transaction wont be initiated or a 
db connection won't be created until some event is triggered on the page to access page definition bindings.

2. If "No Controller Transaction" option is chosen then creation of transaction are totally relied on BC4J. 

3. Chained calls of bounded task flows with no controller transaction option and other transaction options should not be mixed to avoid unpredictable results.

4. Calling a bounded task flow with option use existing transaction from another bounder task flow with option 'always create a new transaction' and both having different 
db connections will cause the caller db connection to be used in the called BTF as well. 

5. 11.1.2 onwards there is no automatic nesting of AM of the called BTF under calling BTF's AM. So prior to 11.1.2 this would have resulted into just 1 AM Pool but now all AMs would be treated as root AM and having their own pool (unless they are explicitly nested at design time). Needless to say they will still share the same transaction/connection (if called BTF has option used exiting transaction (or, if possible))

Tuesday, August 2, 2011

Forcing weblogic server to pick project defined libraries

While building a web application using external jars you may frequently hit issues of having multiple jars containing different versions of same class in the class path and thus unable to run your app. In case of weblogic server you can always force the server to pick classes from your included libraries instead of from other places.
To do it just put the following lines in the weblogic.xml


<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>

In case weblogic.xml does not exist in your app then right click web project and click new. Go to deployment descriptors and choose weblogic.xml. This should generate a weblogic.xml file for you in case of jdeveloper.