Invoking server-side methods from JavaScript using RemoteCommand
RemoteCommand component provides an option to invoke server-side methods, say JSF managed bean methods, from JavaScript client-side code directly. This feature comes in handy when some task needs some client-side action and server-side logic. When you declare a RemoteCommand
component to invoke a JSF managed bean method, then you can call it like a JavaScript function, with the remoteCommand
name from the JavaScript code.
Suppose in our user
Registration Form, we want to validate e-mail format first on client side using Regex and if it is in valid e-mail format, then we want to check whether the e-mail is already in use or not using server-side logic. We can do this by using the RemoteCommand
component.