我正在使用primefaces和jsf实现推送通知我尝试了这段代码,但是通知我是这样的NotifyResource
import javax.faces.application.FacesMessage;
import org.primefaces.push.annotation.OnMessage;
import org.primefaces.push.annotation.PushEndpoint;
import org.primefaces.push.impl.JSONEncoder;
@PushEndpoint("/notify")
public class NotifyResource {
@OnMessage(encoders = { JSONEncoder.class })
public FacesMessage onMessage(FacesMessage message) {
return message;
}
}
但未显示通知
<h:body>
<p:growl widgetVar="growl" showDetail="true" />
<h:form>
<h:panelGrid columns="2">
<p:outputLabel for="summary" value="Summary: " />
<p:inputText id="summary" value="#{notifyView.summary}"
required="true" />
<p:outputLabel for="detail" value="Detail: " />
<p:inputText id="detail" value="#{notifyView.detail}" required="true" />
</h:panelGrid>
<p:commandButton value="Send" actionListener="#{notifyView.send}" />
</h:form>
<p:socket onMessage="handleMessage" channel="/notify" />
<script type="text/javascript">
function handleMessage(facesmessage) {
facesmessage.severity = 'info';
PF('growl').show([facesmessage]);
}
</script>
</h:body>
</html>
任何人都可以帮助我吗?我正在使用primefaces 6.0和氛围2.4.0