Aide FacesMessage p:socket
Bonjour ,
Je voudrais s'il vous plait tester l'exemple du primefaces concernant le PrimePush - FacesMessage http://www.primefaces.org/showcase/p...cesmessage.jsf
et donc j'ai fait ceci :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 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">
<h:head>
<title>kcvdpok</title>
</h:head>
<body>
<p:growl id="growll" widgetVar="growl" showDetail="true" />
<h:form>
<p:panel header="Growl">
<h:panelGrid columns="2">
<p:inputText id="summary" value="#{growlBean.summary}"
required="true" />
<p:inputText id="detail" value="#{growlBean.detail}" required="true" />
</h:panelGrid>
<p:commandButton value="Send" actionListener="#{growlBean.send}" />
</p:panel>
</h:form>
<p:socket onMessage="handleMessage" channel="/notifications" />
<script type="text/javascript">
function handleMessage(facesmessage) {
facesmessage.severity = 'info';
PF('growl').show([facesmessage]);
}
</script>
</body>
</html> |
et
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| package com.mkyong;
import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.primefaces.push.PushContext;
import org.primefaces.push.PushContextFactory;
public class GrowlBean implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private String summary;
private String detail;
public String getDetail() {
return detail;
}
public void setDetail(String detail) {
this.detail = detail;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public void send() {
System.out.println("ok");
PushContext pushContext = PushContextFactory.getDefault().getPushContext();
pushContext.push("/notifications", new FacesMessage(summary, detail));
}
} |
en éxécutant j'obtiens mon message "ok" mais je n'arrive pas à afficher la notification du
Code:
pushContext.push("/notifications", new FacesMessage(summary, detail));
dans ma page web.
Je voudrais bien que vous m'aidiez s'il vous plait parce que ça bloque.
Merci