How does JSF2.0 bind managed Beans to xhtml?

I have a very simple question about how does JSF2.0 bind Managed Beans to xhtml?

let's say I have an inputtext with value = "# {MymanagedBean.property}"

how is this MymanagedBean reference resolved in JSF 2?

consider the following points when responding.

  • in the ealier version, that is, with JSF 1.2, we have to write the binding in faces-config.xml but with JSF 2 it is not necessary to have faces-config.xml

  • If you browse the source of the xhtml pages you will not find the MymanagedBean reference.

how is it done?

+2


a source to share


2 answers


in the ealier version, that is, with JSF 1.2, we have to write the binding in faces-config.xml, but with JSF 2, it is not necessary to have faces-config.xml

In JSF2, this is done using annotation @ManagedBean

.

@ManagedBean
public class MymanagedBean {
    // ...
}

      



During Webapp startup, JSF scans the classpath for all classes using this annotation and collects them in memory.

if you browse the source of the xhtml pages .. you will not find MymanagedBean links.

It is right. JSF runs on the server, creates an HTML page (X), and the web server sends it to the web browser. The web browser has no concept of JSF or any other server side languages. Webbrowser only understands HTML, CSS and JavaScript.

+4


a source


During Webapp startup, JSF will scan the classpath for all classes with this annotation and collect them in memory.



Wow! This will most likely make the application start slowly, especially if your application has thousands of class files.

-1


a source







All Articles