Friday, May 4, 2012

ADF: Programmatic Redirection


Below is the way to programmatic navigate to other view:
    public void redirectToSelf(String viewId) {
        FacesContext fctx = FacesContext.getCurrentInstance();
        ExternalContext ectx = fctx.getExternalContext();
        ControllerContext controllerCtx = null;
        controllerCtx = ControllerContext.getInstance();
        String activityURL = controllerCtx.getGlobalViewActivityURL(viewId);
        try {
            ectx.redirect(activityURL);
        } catch (IOException e) {
            //Can't redirect
            e.printStackTrace();
        }
    }
Note: For executing "controllerCtx.getGlobalViewActivityURL", the view must be present in adfc-config.xml .

No comments:

Post a Comment