navigation rule causes JSF1064: Unable to find or serve resource

前端 未结 1 629
抹茶落季
抹茶落季 2021-01-21 14:29

I\'ve the following xhtml page, that is wrapped in the major part of the other pages in my project:



        
相关标签:
1条回答
  • 2021-01-21 15:00

    That can happen if JSF can't find the matching navigation rule. It'll then switch to implicit navigation. I.e. the outcome will be used as the actual view ID, relative to the current context.

    Apparently the current view ID is sitting somewhere in /protected/personal. An outcome of searchingResults which doesn't match any navigation rule will then trigger an implicit navigation to /protected/personal/searchingResults.xhtml.

    You've 2 options:

    1. Fix the current view ID. The <from-view-id>/Components/TopBar.xhtml</from-view-id> is apparently wrong. You can find out the right one as follows:

      System.out.println(FacesContext.getCurrentInstance().getViewRoot().getViewId());
      

      It's usually the one matching the context-relative URI in browser's address bar as long as you don't use POST for page-to-page navigation. Use this value in <from-view-id>.

    2. Get rid of navigation cases altogether and rely on implicit navigation. Remove the <navigation-case> altogether from faces-config.xml and change the outcome value and action method as below:

      private final String resultsOutcome = "/protected/SearchResults.xhtml";
      
      public String search() {
          return resultsOutcome;
      }
      

      The NavigationHandler approach was also quite clumsy. Even with navigation cases, just return the outcome outright instead of fiddling with NavigationHandler.

    See also:

    • Communication in JSF 2 - Implicit Navigation
    • What is the difference between redirect and navigation/forward and when to use what?
    • Differences between action and actionListener
    0 讨论(0)
提交回复
热议问题