How-to efficiently redirect to an ADF Faces view using ADF Controller

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
Comments:

Very nice! It works correctly for me.

Posted by guest on August 13, 2012 at 08:51 PM BST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

logo
A blog maintained by the JDeveloper product management team. We'll use it to post announcements, occasional how-to's and any other relevant information around JDeveloper and ADF.

See other PM Blogs

Shay, Frank, Grant, Duncan, Chris, Steve ,Joe, Dana, Many more in our blog feed
Follow JDeveloper on Twitter and Facebook

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today