JSF--Managed Beans
一、beans在 faces-config.xml中的定義
格式如下:






在bean定義之后,就可以通過JSF組件來訪問Bean的屬性。
如 <h:inputSecret value="#{user.password}"/>,訪問userbean的password屬性。
二、Message Bundle
自定義資源文件com/corejsf/messages.properties,通過f:loadBundle訪問
<f:loadBundle basename="com.corejsf.messages" var="msgs"/>
basename : properties文件的路徑
var: 文件定義的message key
com/corejsf/messages_de.properties.
國際化,在默認資源文件的基礎上,增加后綴,標識語言類別。
語言默認顯示設置
You can add a locale attribute to the f:view element, for example <f:view locale="de">
You can set the default and supported locales in WEB-INF/faces-config.xml (or another application configuration resource):
<faces-config> <application> <locale-config> <default-locale>en</default-locale> <supported-locale>de</supported-locale> </locale-config> </application> </faces-config>三、Backing Beans
四、Bean Scope
Request
Session
Application
五、Configure Bean
設置屬性值
<managed-bean>
<managed-bean-name>user</managed-bean-name>
<managed-bean-class>com.corejsf.UserBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>name</property-name>
<value>me</value>
</managed-property>
<managed-property>
<property-name>password</property-name>
<value>secret</value>
</managed-property>
</managed-bean>
設置null值
<managed-property>
<property-name>password</property-name>
<null-value/>
</managed-property>
posted on 2007-04-26 14:00 風人園 閱讀(559) 評論(0) 編輯 收藏 所屬分類: JSF