1

I have multiple pages, and on some, the FacesMessage appears, while on others they don't. But I can't figure out why. In my example below, ajax is at false, but on some ajax is at true like everywhere else, but not working even it's same code

In every case the method is called, log proves it, but the message did not show in some case

I have a menu bar, which is included on top of every page, as

<html xmlns="http://www.w3.org/1999/xhtml" xlmns:h="http://java.sun.com/jsf/html" xlmns:f="http://java.sun.com/jsf/core" xlmns:ui="http://java.sun.com/jsf/facelets" xlmns:p="http://primefaces.org/ui">
  <f:view contentType="text/html">
    <h:head>
       <f:facet name="first"> 
            <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
            <title>LOG</title>
        </f:facet>
        <h:body>
            <p:growl showDetail="true" sticky="true">  
                <p:autoUpdate disabled="false" /> 
            </p:growl>
            ...
            <p:layout>
                <p:layoutUnit position="center">
                    <ui:insert name="center" />
                </p:layoutUnit>
            </p:layout>
        </h:body>
      </f:view>
</html> 

And working page is like

<!DOCTYPE HTML PUBLIC>
<ui:composition template="/menu.xhtml"  xmlns="http://www.w3.org/1999/xhtml" 
         xlmns:h="http://java.sun.com/jsf/html" xlmns:f="http://java.sun.com/jsf/core" 
         xlmns:ui="http://java.sun.com/jsf/facelets" xlmns:p="http://primefaces.org/ui">
    <ui:define name="center>
        <h:form >
            <p:commandButton action="#{firstBean.method()}" />
        </h:form>
    </ui:define>
</ui:composition>

Not working page is like (here ajax at false, but there is also non-working page with ajax true) :

<!DOCTYPE HTML PUBLIC>
<ui:composition template="/menu.xhtml"  xmlns="http://www.w3.org/1999/xhtml" 
         xlmns:h="http://java.sun.com/jsf/html" xlmns:f="http://java.sun.com/jsf/core" 
         xlmns:ui="http://java.sun.com/jsf/facelets" xlmns:p="http://primefaces.org/ui">
    <ui:define name="center>
        <h:form enctype="mulipart/form-data" >
            <h:inputFile value="#{secondBean.inputFile}" />
            <p:commandButton ajax="false" action="#{secondBean.method()}"  process="@form" />
        </h:form>
    </ui:define>
</ui:composition>

And both method() are 100% same :

public void method(){
    new JSFUtils().sendMessage("Test 1");
    Logger.getAnonymousLogger().severe("Test"); // Always worked, always called
    //...
}

Where I have an util class

public calss JSFUtil{
    public void sendMessage(String msg){
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(Faces.Message.SEVERITY_WARN, "Warn", msg));
    }
}
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
azro
  • 53,056
  • 7
  • 34
  • 70

0 Answers0