The Monaco widget provides forwards several events from the JavaScript API as AJAX behavior events for your convenience. You can use <p:ajax> to attach a server-side listener to the event, or the on[eventname] attributes to attach a client-side callback. In case you require more fine-tuned control or wish to listen to an event not supported by this widget, consider using Monaco editor's client-side API directly; possibly in combination with a <p:remoteCommand> or <pe:remoteCommand> if you need to invoke a client-side listener.

Supported events are:
  • blur
  • change
  • focus
  • initialized (after the Monaco editor was rendered)
  • keydown
  • keyup
  • mousedown
  • mousemove
  • mouseup
  • paste
Note that if you value performance, you should avoid adding server-side listeners for frequently occurring events such as mousemove etc. In this example, we display a growl message via PrimeFace's client-side JavaScript API in the onstart callback of the AJAX behavior and return false to cancel the AJAX request to the server; but you could call a server-side method here if you wanted.
${showcase:getFileContent('/sections/monacoEditor/example-events.xhtml')} ${showcase:getFileContent('/org/primefaces/extensions/showcase/controller/MonacoEditorController.java')}