Monday, July 4, 2011

ADF Auto-Redirect while still Passing URL Parameters (with ADF Security)

This blog is meant to share my findings in sending URL parameters in the case of a redirect. The main use-case for this setup is when I'm trying to launch a bounded taskflow which can be invoked via url. As you might have noticed, a bounded taskflow url is not really user friendly hehe, so what I did is that I have a page which can be defined in the contextRoot settings of your project and that page will have a pagePhaseListener to redirect the user to the bounded taskFlow. As an added test, I also turned on ADF security to test the same use-case.

I've created a bounded taskflow with a single input parameter and also configured for url invoke.

main-flow-index-xml

main-flow-index.xml (property)

MainFlowIndexPage.jspx

So with this URL:
http://localhost:7101/ParameterRetrieval/faces/adf.task-flow?adf.tfId=main-flow-index&adf.tfDoc=/WEB-INF/main-flow-index.xml&inputParam=myTestInputValue

We would get this page:


So, onward to the how-to redirect. For this I had to use a cool article by Andrejus regarding Security in Oracle ADF and Automatic Page Loading. So basically, we are going to make our own PagePhaseListener and as best practice dictates, we'll extend this object to a backing bean object which we will configure in our proxy's pageDef. So lets start.

TestPageRedirect.java

TestPageRedirect.java - Implemented object of the PagePhaseListener where we trigger our redirect at the PrepareModel phase.

TestBacking.java

TestBacking.java - Here's our backingBean object which extends our TestPageRedirect. We've already configured our onLoad to trigger our redirect which is based on F. Nimphius article on How-to efficiently redirect to an ADF Faces view using ADF Controller.

Next, we're going to configure our pageDef, well defined the backingBean in the taskflow as well.

adfc-config.xml

TestRedirect.jspx

TestRedirectPageDef.xml

TestRedirectPageDef.xml - configure the ControllerClass to point to our backingBean.

After all of that is setup, we can now run TestRedirect.jspx and this should redirect us to our bounded taskflow.

Launching:

http://localhost:7101/ParameterRetrieval/faces/TestRedirect.jspx?inputParam=12345

will take us now to our bounded taskflow.


Success! So as an additional, lets add ADF Security :)

Lets launch: http://localhost:7101/ParameterRetrieval/faces/TestRedirect.jspx?inputParam=myHelloWorld

LoginPage

No comments:

Post a Comment