开发者

How JSF2.0 binds Managed Beans with xhtml?

i have very basic question about How JSF2.0 binds Managed Beans with xhtml?

say i have inputtext with value="#{MymanagedBean.property}"

how this MymanagedBean reference is resolved in JSF 2 ?

plea开发者_如何学编程se consider following points while answering.

  1. in ealier version i.e. with JSF 1.2 we have to write binding in faces-config.xml but with JSF 2 it is not mandatory to have faces-config.xml

  2. if you do view source of xhtml pages.. you will not find anywhere MymanagedBean reference.

then how it is done?


in ealier version i.e. with JSF 1.2 we have to write binding in faces-config.xml but with JSF 2 it is not mandatory to have faces-config.xml

In JSF2 this is done by the @ManagedBean annotation.

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

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

if you do view source of xhtml pages.. you will not find anywhere MymanagedBean reference.

That's correct. JSF runs at the server machine, produces a (X)HTML page and the webserver sends it to the webbrowser. The webbrowser has no notion of JSF or any other server side languages. The webbrowser only understands HTML, CSS and JavaScript.


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

Wow! That sure will make application startup slow especially if your application has thousands of class files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜