呆羊在曬太陽 |
|
|||
公告
日歷
統(tǒng)計(jì)
導(dǎo)航常用鏈接留言簿(7)隨筆分類(158)
文章分類(2)相冊(cè)log搜索積分與排名
最新評(píng)論
閱讀排行榜
|
You usually set up your web application as you would do with any other JSF web application. The following sample configuration files show you how to enable the above mentioned features.
The web.xml configuration: WEB-INF/web.xml
<?xml version="1.0"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <!-- The filter used to publish A web.xml configuration with net.sourceforge.myfaces JSF-implementation 1.0.2 (because an internal spring-based VariableResolver is used a few features which are not supported by MyFaces yet, e.g. list-entries, map-entries..., are enabled): WEB-INF/web.xml
<?xml version="1.0"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <!-- The filter used to publish ExampleIn this example, we just use two beans:
WEB-INF/faces-config.xml (partial)
<!-- a purely JSF managed bean -->
<managed-bean>
<managed-bean-name>jsfBean</managed-bean-name>
<managed-bean-class>example.NameBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>name</property-name>
</managed-property>
</managed-bean>
<!-- a
WEB-INF/applicationContext.xml (partial)
<!-- a purely Spring managed bean --> <bean id="directAccessSpringBean" class="example.NameBean"/> <!-- a Spring managed bean supplied with a scope within JSF --> <bean id="scopedAccessSpringBean" class="example.NameBean" singleton="false"/> <!-- a purely Spring managed bean being referenced by a JSF managed bean (but which of course can be accessed directly as well) -> <bean id="managedPropertyAccessSpringBean" class="example.NameBean" singleton="false"/>
test.jsp
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <html> <head><title>test</title></head> <body bgcolor="white"> <f:view> <h:messages/> <h:form> purely JSF managed bean: <h:inputText value="#{jsfBean.name}" valueChangeListener="#{jsfBean.valueChanged}"/> <h:commandButton value="action" actionListener="#{jsfBean.action}"/> <br/> purely Spring managed bean: <h:inputText value="#{directAccessSpringBean.name}" valueChangeListener="#{directAccessSpringBean.valueChanged}"/> <h:commandButton value="action" actionListener="#{directAccessSpringBean.action}"/> <br/> scoped Spring managed bean: <h:inputText value="#{scopedAccessSpringBean.name}" valueChangeListener="#{scopedAccessSpringBean.valueChanged}"/> <h:commandButton value="action" actionListener="#{scopedAccessSpringBeanaction}"/> <br/> referenced Spring managed bean: <h:inputText value="#{referencingBean.referencedBean.name}" valueChangeListener="#{referencingBean.referencedBean.valueChanged}"/> <h:commandButton value="action" actionListener="#{referencingBean.referencedBean.action}"/> <br/> <h:commandButton id="submit" action="save" value="save"/> </h:form> </f:view> </body> </html>
|
![]() |
|
Copyright © 小叉 | Powered by: 博客園 模板提供:滬江博客 |