25 September, 2012

ADF : Redirect to another View Programatically

You can use the below method to redirect to another view in ADF programatically.
 
    public static void redirectToView(String viewId) {
        FacesContext fCtx = FacesContext.getCurrentInstance();
        ExternalContext eCtx = fCtx.getExternalContext();

        String activityUrl = ControllerContext.getInstance().getGlobalViewActivityURL(viewId);
        try {
            eCtx.redirect(activityUrl);
        } catch (IOException e) {
            e.printStackTrace();
            JSFUtils.addFacesErrorMessage("Exception when redirect to " + viewId);
        }
    }
 

Thanks

3 comments:

  1. Mahmoud, instead it will be better to use ADF taskflow navigation

    public static void navigateTo(String navigationOutcome) {
    FacesContext context = FacesContext.getCurrentInstance();
    Application application = context.getApplication();
    application.getNavigationHandler().handleNavigation(context, null, navigationOutcome);
    }

    ReplyDelete
  2. Thank you both. this works fine. How do I open the page in a new window though?

    ReplyDelete
  3. Hi to open page in new window use dialog framework
    by setting commndbutton property usewindow true.action property dialog:navigationcase

    ReplyDelete

How to Pass Parameters to ActionListener in ADF

In some cases, it is required to pass a value to ActionListener of ADF Button. The method that can be invoked by actionListeners has only...