简体   繁体   中英

Primefaces p:messages autoupdate not working

I m using autoUpdate property of p:messages but its not working , messages doesn't appears on web page.Interestingly if valdation fails then message get displayed

Sample-

xhtml-

<h:form id="form_1">
  <p:messages autoUpdate="true"  showDetail="true" id="msgs" />
  <table>
    <tr>
      <td>
        <h:outputLabel id="label" style="width:100%" value="Name" />
      </td>
      <td>
        <p:inputText id="text" value="#{userweb.bindUser.uname}" />
      </td>
    </tr>
    <tr>
      <td>
        <h:outputLabel id="label_1" style="width:100%" value="Pwd" />
      </td>
      <td>
        <p:inputText id="text_1" value="#{userweb.bindUser.pwd}" />
      </td>
    </tr>
    <tr>
      <td>
        <h:outputLabel value=" " />
      </td>
      <td>
        <p:commandButton  id="button" value="Save" validateClient="true">
          <p:ajax event="click" listener="#{userweb.saveUser()}" />
        </p:commandButton>
      </td>
    </tr>
  </table>           
</h:form>

ui.xhtml-

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui" template="base.xhtml">


<ui:define name="body">
    <h:body>

        <ui:include src="bodyMain.xhtml" />



        <div id="container">
            <div id="header" class="ui-widget ui-widget-header">
                <ui:include src="header.xhtml" />
            </div>
            <div id="page" class="ui-widget">
            <div id="nav">
                <ui:include src="\leftmenu.xhtml">
                    <ui:param name="menuItem" value="#{impaktNavigator}"></ui:param>
                </ui:include>

            </div>
            <div id="content">
                <ui:insert name="content">...</ui:insert>
            </div>

            </div>
            <div class="clearfooter"></div>
        </div>

        <div id="footer" class="ui-widget ui-widget-header ui-corner-all">
            <p>Running on Impakt 1.1</p>
        </div>




    </h:body>
</ui:define>

base.xhtml-

 <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">

 <f:view contentType="text/html">

<h:head>
    <f:facet name="first">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta content='text/html; charset=UTF-8' http-equiv="Content-Type" />
        <title>Demo</title>

    </f:facet>

    <h:outputStylesheet library="css" name="application.css" target="head" />





</h:head>

<ui:insert name="body"></ui:insert>


</f:view>
</html>

Java-

package webmodule;
import java.io.Serializable;

import javax.faces.application.FacesMessage;
import javax.faces.application.FacesMessage.Severity;
import javax.faces.context.FacesContext;

import model.User;

import org.omnifaces.util.Faces;
import org.springframework.beans.factory.annotation.Autowired;


 public class Userweb implements Serializable 
 {

User bindUser;

@Autowired
public void setBindUser(User bindUser) {
    this.bindUser = bindUser;
}

public User getBindUser() {
    return bindUser;
}

public void saveUser() throws Exception {
    String result = null;
    FacesMessage msg = new FacesMessage("Done", "It worked");
    FacesContext.getCurrentInstance().addMessage(null, msg);


    //return result;
}

 }        

But if i remove autoUpdate and use following then it works-

<p:ajax event="click" listener="#{userweb.saveUser()}" update="msgs" />

I m using- Primefaces 4.0 jsf 2.2.6 (mojarra) Tomcat 7

Plz help me out.....Thanks

通过将JSF 2.2.6降级到JSF 2.2.2开始一切。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM