From the course: Java EE 8: JavaServer Faces JSF 2.3

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Execute backing bean code from Facelets

Execute backing bean code from Facelets

From the course: Java EE 8: JavaServer Faces JSF 2.3

Start my 1-month free trial

Execute backing bean code from Facelets

- [Instructor] We've seen how to trigger JavaScript from the backing bean. This video is the story of how you can trigger the backing bean code from the webpage using JavaScript. This is brand new with JSF 2.3. We used to need the likes of PrimeFaces to do stuff like this, not anymore. An honorable mention to the crew at OmniFaces, again. This feature is based on their implementation of the same functionality, let's crack on. I'll first define a suitable method in the same request called BackingBean I've created. So, let's come here, in our javaToJsBean, create another public void method named triggerJava. Let's open and close that, print some log output here, println, the Javascript triggering works. Let's close that out, save it. Now, I'm not doing anything special here. This method will just print some output, and that's the end of that. Now, let's see how it looks to trigger this method using JavaScript. Let's go…

Contents