JSF: call backing-bean method without rendering the page (using URL parameters)

后端 未结 1 406
鱼传尺愫
鱼传尺愫 2021-01-07 07:40

Is it possible to use a JSF (PrimeFaces) page in the following fashion ? :

  1. external application (not JSF-based) does an
1条回答
  •  礼貌的吻别
    2021-01-07 08:27

    Use to set GET parameters as bean properties and use to execute a bean action and use NavigationHandler to perform navigation programmatically.

    View:

    
        
        
        
    
    

    Bean:

    public void action() {
        // ...
    
        FacesContext context = FacesContext.getCurrentInstance();
        NavigationHandler navigationHandler = context.getApplication().getNavigationHandler();
        navigationHandler.handleNavigation(context, null, "outcome");
    }
    

    Note that, depending on the concrete functional requirement, JSF might not necessarily be the right tool for the job. I'd investigate if you couldn't better use a servlet filter or even a plain servlet for the purpose.

    See also:

    • What can , and be used for?
    • Hit a bean method and redirect on a GET request

    0 讨论(0)
提交回复
热议问题