How to add MyFaces support to a Sun JSF RI application

How to add MyFaces support to a Sun JSF RI application

Introduction

MyFaces does have its own implementation of the JSF specification. But if you already have a working JSF web app based on the Sun JSF 1.1 reference implementation, you may want stay with it. The following describes the minimal steps necessary to add the MyFaces extensions to a Sun JSF 1.1 web app.

  • Versions these steps should work for:

    • Sun JSF 1.1.01

    • MyFaces 1.0.9 (success with version 1.1.1 has also been reported)

  • Notes:

    • The MyFaces version of Tiles Support will not work with this approach, but other components should work fine.

Steps
  • Put the myfaces-extensions.jar and the commons-fileupload-1.0.jar in your WEB-INF/lib directory (or in the classpath of your application server.)

  • Add the following lines to your web.xml file:

<!-- Extensions Filter -->
<filter>
        <filter-name>extensionsFilter</filter-name>
        <filter-class>
                org.apache.myfaces.component.html.util.ExtensionsFilter
        </filter-class>
        <init-param>
                <description>
                        Set the size limit for uploaded files. Format: 10 - 10
                        bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB
                </description>
                <param-name>uploadMaxFileSize</param-name>
                <param-value>100m</param-value>
        </init-param>
        <init-param>
                <description>
                        Set the threshold size - files below this limit are
                        stored in memory, files above this limit are stored on
                        disk.
                        Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB
                </description>
                <param-name>uploadThresholdSize</param-name>
                <param-value>100k</param-value>
        </init-param>
        <!--
        <init-param>
                <param-name>uploadRepositoryPath</param-name>
                <param-value>/temp</param-value>
                <description>Set the path where the intermediary files will be stored.
                </description>
        </init-param>
        -->
</filter>
<filter-mapping>
        <filter-name>extensionsFilter</filter-name>
        <url-pattern>*.faces</url-pattern>
</filter-mapping>
<filter-mapping>
        <filter-name>extensionsFilter</filter-name>
        <url-pattern>/faces/*</url-pattern>
</filter-mapping>

Note: you may need to change the url-pattern to match whatever pattern you are using (e.g. *.jsf instead of *.faces).

  • Add the following to your JSP page in order to use one of the MyFaces custom components:

<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%> 

That's it! You should now be able to add MyFaces components to your .jsp page.

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值