X

The blog for hints & tips about Oracle Application Development Framework and Mobile Application Framework

How-to efficiently redirect an ADF Faces view using ADFc

Frank Nimphius
Master Principal Product Manager

ADF Faces developers use
facesContex.getExternalContext().redirect(String) to issue a GET request to a
JSF view. Using ADFc, the redirect URL should neither be read from the current
UIView root directly or provided in the form /faces/<viewId name>.
Instead, have the controller generating the redirect String for a specific
viewId as shown below:

FacesContext
fctx = FacesContext.getCurrentInstance();
ExternalContext
ectx = fctx.getExternalContext();

String
viewId = "... add viewId...."
ControllerContext
controllerCtx = null;
controllerCtx
= ControllerContext.getInstance();
String
activityURL = controllerCtx.getGlobalViewActivityURL(viewId);

try{
ectx.redirect(activityURL);
}
catch (IOException e) {
//Can't redirect
e.printStackTrace();

}

Why? Because a redirect is a Get request and you don't want
ADFc to treat it as a new application request but instead retrieve the internal
controller state. For this you need the state toke in the redirect URL, which
is what the code line above does

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.