Passing URL parameters using Java ADF

Off late i have been asked this question a lot as to how to pass URL parameters in a Java ADF web application similar to ArcIMS HTML Viewer.

For example : You would like to open the web app and zoom to a given envelope

In terms of URL :,65.87,-90.50,68.44

Other use cases might be :

  • Turning on/off layers
  • Adding resources dynamically
  • Passing an authentication token
  • Perform a query and show results on the graphic layer

Probably the easiest way of doing this is by tapping into the lifecycle of the web application using the Interface WebContextInitialize.

This can be done is three easy steps :

  1. Implement the Java class
  2. Register this class as managed bean in faces-config.xml
  3. Add this managed bean as an custom attribute to the WebContext in faces-config.xml

Step 1 : Here is the basic skeletal code for the Java class

import javax.faces.context.FacesContext;
import com.esri.adf.web.util.WebUtil;

public class MyParamsHandler implements WebContextInitialize {
public void init(WebContext webContext) {
java.util.Map params = null;
params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
//alternative way of getting the context or request parameters
//params = WebUtil.getExternalContext().getRequestParameterMap();
if (params != null && params.get("action") != null) {

//parse out the string you are looking for and implement your business logic here
String action = params.get("action").toString();

//House keeping
WebMap webMap = webContext.getWebMap();
WebExtent currExtent = webMap.getCurrentExtent();

if ("zoomin".equalsIgnoreCase(action)) {
} else if ("zoomout".equalsIgnoreCase(action)) {
} //end of if
}//end of method
} //end of class

Step 2 : Register the class as Managed bean in face-config.xml file:


Step 3 : Add the managed bean as a custom attribute to the WebContext managed bean in faces-config.xml


2 Responses to “Passing URL parameters using Java ADF”

  1. khalil Says:

    may my replay be late but I thing there is easier way to pass request parameters to your beans:

    setManagedProperty in the ManagedBean tag in faces-config.xml ::



    in Mine Bean there should be an attribute with myParam name and with setters and getters..

    in the URL :

    so in the setMyParam()
    the value 2 will be set

  2. Smithf741 Says:

    There is visibly a bundle to realize about this. I assume you made certain nice points in features also. bdcgcfbckkkabbbb

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: