Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

JavaScript API to register websocket event listeners #1442

Closed
glassfishrobot opened this issue Feb 20, 2017 · 3 comments
Closed

JavaScript API to register websocket event listeners #1442

glassfishrobot opened this issue Feb 20, 2017 · 3 comments

Comments

@glassfishrobot
Copy link

I would like to note that in my view the current way to specify JavaScript callbacks for websocket events by referring to JavaScript functions by name isn't very nice. Especially because developers have to define callback functions in the global scope, which is considered as bad practice in modern JavaScript development.

What about something like this:

<f:websocket id="mySocket" channel="push" />

  <script type="application/javascript">
    // register callback using the client id
    jsf.push.addOnMessage('mySocket', function(message) {
      // process message
    });
  </script>

With this API developers won't have to define any global callback functions and they can even dynamically add more listeners at runtime if required. It is somehow similar to jsf.ajax.addOnEvent(), but would always refer to a specific <f:websocket> using the clientId.

Affected Versions

[2.3]

@glassfishrobot
Copy link
Author

Reported by chkal

@glassfishrobot
Copy link
Author

This issue was imported from java.net JIRA JAVASERVERFACES_SPEC_PUBLIC-1442

@glassfishrobot
Copy link
Author

Closing this as this issue is migrated to jakartaee/faces#1442

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants