Tag: jsf
如何使用MyFace快速构建基于JSF的应用
by Elton on 二.02, 2010, under Java
如果大家使用Apache MyFace的JSF实现来搭建JSF应用,可以利用Apache提供的便捷maven方法来快速搭建一个初始的应用。
1 2 3 4 5 6 7 8 9 10 | mvn archetype:generate -DarchetypeCatalog=http://myfaces.apache.org …… Choose archetype: 1: http://myfaces.apache.org -> myfaces-archetype-helloworld (Simple Web application using Apache Myfaces) 2: http://myfaces.apache.org -> myfaces-archetype-helloworld-facelets (Simple Web application using Apache Myfaces and Facelets) 3: http://myfaces.apache.org -> myfaces-archetype-helloworld-portlets (Simple Web application using Apache Myfaces and Portlets) 4: http://myfaces.apache.org -> myfaces-archetype-jsfcomponents (Simple JSF Component using Apache Myfaces) 5: http://myfaces.apache.org -> myfaces-archetype-trinidad (Simple Web application using Apache Myfaces and Trinidad) Choose a number: (1/2/3/4/5): …… |
可以看到它提供了你5个初始项目进行选择,你可以根据你的需要选择响应的选项。之后填写响应的参数后,你的应用程序框架就生成了。
然后再使用以下命令,来下载必要的依赖包,假设你的groupId=myAppId,artifactId=yourapp
1 2 | cd yourapp
mvn package |
之后你就搭建了一个初始框架,你可以继续使用maven来操作这个框架。
在JBOSS服务器上使用Myfaces的JSF实现
by Elton on 一.16, 2010, under Java
JBOSS AS服务器默认使用的JSF实现是SUN的RI,要把他替换成Myfaces需要:
1.移除JBoss服务器的现有的JSF实现RI
修改JBOSS_HOME下的server< config-name>deployjboss-web.deployerconfweb.xml文件,把JSF的监听器注掉,并删除jboss-web.deployer 目录下的jsf-libs文件夹
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <!-- <context-param> <param-name>com.sun.faces.injectionProvider</param-name> <param-value>org.jboss.web.jsf.integration.injection.JBossInjectionProvider</param-value> </context-param> --> <!-- Comment/Remove this --> <!-- Configures JSF for a web application if the javax.faces.webapp.FacesServlet is declared --> <!-- in web.xml. --> <!-- <listener> <listener-class>org.jboss.web.jsf.integration.config.JBossJSFConfigureListener</listener-class> </listener> --> <!-- Comment/Remove this --> <!-- Listens to all web app lifecycle events so that @PreDestroy can be called on --> <!-- JSF managed beans that go out of scope. You can comment this out if you --> <!-- don't use JSF or you don't use annotations on your managed beans. --> <!-- <listener> <listener-class>com.sun.faces.application.WebappLifecycleListener</listener-class> </listener> --> |
2.安装Myfaces的JSF实现
在jboss-web.deployer 目录下新建myfaces-libs文件夹,并把myfaces的实现jar包拷贝到里面
1 2 3 4 5 6 | commons-beanutils.jar commons-digester-1.6.jar commons-el.jar commons-lang-2.1.jar myfaces-api.jar myfaces-impl.jar |
在jboss-web.deployerconfweb.xml中添加myfaces的监听器
1 2 3 | <listener> <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class> </listener> |
3.修改jboss-web.deployerconfweb.xml中JSF相关的init-param参数,替换
1 2 3 4 5 6 7 8 9 10 | <init-param> <description>JSF standard tlds</description> <param-name>tagLibJar0</param-name> <param-value>jsf-libs/jsf-impl.jar</param-value> </init-param> <init-param> <description>JSTL standard tlds</description> <param-name>tagLibJar1</param-name> <param-value>jstl.jar</param-value> </init-param> |
为
1 2 3 4 5 | <init-param> <description>MyFaces tlds</description> <param-name>tagLibJar0</param-name> <param-value>myfaces-libs/myfaces-impl.jar</param-value> </init-param> |
现在启动JBOSS AS就可以看到加载的已经加载了Myfaces的JSF。可以在JBOSS服务器上使用Myfaces的JSF实现了。


