2
votes

I have a problem with the warning: Could not resolve NavigationCase for outcome:....

com.sun.faces.application.resource.ResourceHandlerImpl logMissingResource
WARNUNG: JSF1064: Resource /common-content.xhtml not resolvable

The warning does not seem to have any affect to my application since i leverage the implicit navigation using JSF 2 with Mojarra 2.2.8 and Primefaces 3.5. I didn't define any navigation-case within the faces-config.xml

The interesting thing about it, is that navigation itself works properly, but the warning is added to the Faces message queue and therefor shown within any message after a request.

The following code shows my home.xhtml which

<h:body class="page-container">
    <p:growl id="message"></p:growl>

        <div class="page-layout-container">
            <div>   
                <ui:insert name="header">
                    <ui:include src="/template/puh-common-header.xhtml" />
                </ui:insert>            
            </div>
            <div> 
                <ui:insert  name="menu">
                            <ui:include src="/template/puh-menu.xhtml" />
                        </ui:insert>
            </div>
            <div>
                <h:panelGroup id="content" layout="block">
                <ui:insert name="content">
                    <ui:include src="/main-content/#{mainContentController.getContent()}"/>
                </ui:insert>
                </h:panelGroup>
            </div>          
            <div>
                <ui:insert name="footer">
                    <ui:include src="/template/puh-common-footer.xhtml" />
                </ui:insert>
            </div>

        </div>

</h:body>

The page just includes the appropriate compositions. I think here is the problem. The outcome is always home.xhtml the pages referenced by the JSF warning are just compositions.

Edit:

The backing bean impementation of mainContentController:

@Named("mainContentController")
@SessionScoped
public class MainContentController implements Serializable {    

    /**
     * 
     */
    private static final long serialVersionUID = -6818446964735212239L;



    private Logger logger = LogManager.getLogger(MainContentController.class);

    public static String PAGE_HOME = "puh-home.xhtml";

    public static final String CONTENT_ERROR = "puh-error.xhtml";

    public static String CONTENT_COMMON = "puh-common-content.xhtml";

    public static String CONTENT_CONTACT = "puh-contact.xhtml";

    public static String CONTENT_REPAIR = "puh-repair.xhtml";

    public static String CONTENT_IMPRESSUM = "puh-impressum.xhtml";

    private String content = CONTENT_COMMON;

    private void showControllerState() {
        logger.info("Page "+ content + ".");        
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Page "+ content + "."));
    }

    public String homeAction() {
        content = CONTENT_COMMON;               
        showControllerState();
        return content;
    }

    public String serviceAction() {
        content = CONTENT_REPAIR;               
        showControllerState();
        return content;
    }

    public String impressumAction() {
        content = CONTENT_IMPRESSUM;
        showControllerState();
        return content;
    }

    public String contactAction() {
        content = CONTENT_CONTACT;
        FacesContext facesContext = FacesContext.getCurrentInstance();
        String outcome = PAGE_HOME+"?faces-redirect=true"; // Do your thing?

        // Because of Captcha Image   
        facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, null, outcome); 
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Redirect "+ content + "."));           
        showControllerState();
        return content;
    }


public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

}
2

2 Answers

0
votes

What does the managed bean function here return?:

<ui:insert name="content">
<ui:include src="/main-content/#{mainContentController.getContent()}"/>
</ui:insert>

because according to the warning:

WARNUNG: JSF1064: Resource /common-content.xhtml not resolvable

The file you are referencing does not seem to exist in the location which you have specified. It would also help if you posted the file structure of your project.

0
votes

I solved the warning but ran into real problems.

I changed the following code snippet

<div>
   <h:panelGroup id="content" layout="block">
     <ui:insert name="content">
       <ui:include src="/main-content/#{mainContentController.getContent()}"/>
     </ui:insert>
  </h:panelGroup>
</div> 

I added the static "/main-content" path to the return value of the method "mainContentController.getContent()" which belongs to the dynamic Expression Language statement #{mainContentController.getContent().

The result is <div> <h:panelGroup id="content" layout="block"> <ui:insert name="content"> <ui:include src="#{mainContentController.getContent()}"/> </ui:insert> </h:panelGroup> </div>

and the backing bean looks like this

public class MainContentController implements Serializable {

   private Logger logger = LogManager.getLogger(MainContentController.class);

   public static String PAGE_HOME = "puh-home.xhtml";

   public static String CONTENT_COMMON = "/main-content/puh-common- content.xhtml";

   private String content = CONTENT_COMMON; 

   public String getContent() {
     return content;
   }

   public void setContent(String content) {
     this.content = content;
   }

   private void handleNavigation() {
      logger.info("Navigate to page "+  content + ".");             
      FacesContext facesContext = FacesContext.getCurrentInstance();
      String outcome = PAGE_HOME+"?faces-redirect=true";          facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, null, outcome);           
    }

    public String homeAction() {
        content = CONTENT_COMMON;               

        handleNavigation();
        return content;
  }
}

I don't have a real answer for this kind of behaviour right now but i think the problem is related to the life cycle of JSF.

To emphasize the issue.

There is differnence between

1. <ui:include src="/main-content/#{mainContentController.getContent()}"/>

and

2. <ui:include src="#{mainContentController.getContent()}"/>

Both statements (1 and 2) result into to exactly the same path but the behaviour of the container is different.