Java Server Faces, otherwise known as JSF, is a Model-View-Controller framework that allows you to create applications that separate business logic from the view layer. MVC architecture allows applications greater scalability, since changes in any business logic will not affect what the end user sees. In addition, the view layer can be rendered in several ways.
For example, some users might be using a browser, whereas other users might be viewing an application through their smart phones. You implement the business logic once to be used by both views.
In order to pass information from one JSF page to another, you need to either save information in a managed bean using the request, session, or application scope OR directly on the scope objects themselves. A managed bean is simply a Java bean that has been registered in the faces-config.xml file which resides in the WEB-INF directory. You can then reference the bean using Expression Language (EL). Suppose you have already registered a Java bean whose fully-qualified class name is com.fbtraining.MyBean with a logical name of “MyBean”. Also assume that this bean has a String property called “msg”. You would then reference the bean from your JSF code like this: #{MyBean.msg}
When you have an input field whose value is #{MyBean.msg}, during runtime your application implicitly calls the getter method for the property when rendering the component. When submitting the form, the setter method is implicitly called.
Please Share This Knowledge With Others!