jeudi 12 février 2015

Primefaces WebSocket socket.css socket.js undefined


I've already done some googling about this problem, but unfortunately I haven't found a solution yet.


First of all, I'm using Primefaces 5.1, Primefaces PUSH 2.0, Glassfish 4.1, JSF 2.2 in my project.


The WebSocket works fine but only after cleaning cache by pressing CTRL + F5. If I don't, the browser crashes and I get the following messages (that's why it only works after CTRL + F5):


GET http://localhost:8080/zzz/javax.faces.resource/socket/socket.css.jsf?ln=primefaces&v=5.1 2015-02-11 13:55:08.854jquery.js.jsf?ln=primefaces&v=5.1:25


GET http://localhost:8080/zzz/javax.faces.resource/socket/socket.js.jsf?ln=primefaces&v=5.1 404 (Not Found)


I'm using facelets in my xhtml files. So, I have a main-template.xhtml where I've put the JavaScript to handle the WebSocket requests, as you can see below:



<h:head>

<!-- some stuff here... -->

<script type="text/javascript">
console.log('> Alive');
function handleMessage(data) {
/*data.severity = 'info';
PF('growl_info_wdgt').show([data]);*/

console.log('handleMessage - ' + data);
receiveMessage([{name:'msgData', value:data}]);
}

function handleOpen(data) {
console.log('handleOpen - ' + data);
}

function handleClose(data) {
console.log('handleClose - ' + data);
}

/*I've seen this code as workaround approach for a
similar problem with Primefaces Mobile, as you can see
in this link: http://ift.tt/1KJzJfF
Without using this workaround, the message error is the
same as shown in the previous link;

*/
var originalPrimeFacesCw = PrimeFaces.cw;
PrimeFaces.cw = function(name, id, options, resource) {
resource = resource || name.toLowerCase();
originalPrimeFacesCw.apply(this, [name, id, options, resource]);
};
</script>
</h:head>


In my page.xhtml is where I have a webSocket listener, as shown below:



<p:socket
channel="/zzz"
onMessage="handleMessage"
/>


So, can someone help me with this problem?


Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire