My web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.4"
         xmlns="http://java.sun.com/xml/ns/j2ee";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";>

    <display-name>JSF Facelets Trail</display-name>

    <!-- Use Documents Saved as *.xhtml -->
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>

    <context-param>
        <param-name>facelets.LIBRARIES</param-name>
        <param-value>
            
/WEB-INF/facelets/tomahawk.taglib.xml;/WEB-INF/facelets/sandbox.taglib.xml;/WEB-INF/facelets/fsds.taglib.xml;
        </param-value>
    </context-param>


    <!-- Special Debug Output for Development -->
    <context-param>
        <param-name>facelets.DEVELOPMENT</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <param-name>facelets.REFRESH_PERIOD</param-name>
        <param-value>2</param-value>
    </context-param>

    <context-param>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>

    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>

    <context-param>
        <description>
            This parameter tells MyFaces if javascript code should be
allowed in the
            rendered HTML output.
            If javascript is allowed, command_link anchors will have
javascript code
            that submits the corresponding form.
            If javascript is not allowed, the state saving info and
nested parameters
            will be added as url parameters.
            Default: "true"
        </description>
        <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
        <param-value>false</param-value>
    </context-param>

    <context-param>
        <description>
            If true, rendered HTML code will be formatted, so that it
is "human readable".
            i.e. additional line separators and whitespace will be
written, that do not
            influence the HTML code.
            Default: "true"
        </description>
        <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <description>
            If true, a javascript function will be rendered that is
able to restore the
            former vertical scroll on every request. Convenient
feature if you have pages
            with long lists and you do not want the browser page to
always jump to the top
            if you trigger a link or button action that stays on the same page.
            Default: "false"
        </description>
        <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
        <param-value>true</param-value>
    </context-param>

    <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>2m</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>64k</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>*.jsf</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>extensionsFilter</filter-name>
        <url-pattern>/faces/*</url-pattern>
    </filter-mapping>

    <listener>
        
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
    </listener>

    <!-- Faces Servlet -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet>
        <servlet-name>Upload Servlet</servlet-name>
        <servlet-class>upload.UploadServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>Upload Servlet</servlet-name>
        <url-pattern>upload.do</url-pattern>
    </servlet-mapping>

    <!-- extension mapping -->
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.jsf</welcome-file>
    </welcome-file-list>

</web-app>


JSF Faces configuration:

<?xml version="1.0"?>

<!DOCTYPE faces-config PUBLIC
        "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
        "http://java.sun.com/dtd/web-facesconfig_1_1.dtd";>

<faces-config>

    <application>
        <locale-config>
            <default-locale>en</default-locale>
            <supported-locale>zh</supported-locale>
        </locale-config>
        <message-bundle>language.MemberSite</message-bundle>
        <view-handler>
            com.sun.facelets.FaceletViewHandler
        </view-handler>
        <navigation-handler>Navigator</navigation-handler>
    </application>

    <lifecycle>
        <phase-listener>ajax.AjaxListener</phase-listener>
    </lifecycle>

    <converter>
        <converter-id>DebtorTypeTagConverter</converter-id>
        
<converter-class>com.fsds.jsf.convertor.DebtorTypeTagConverter</converter-class>
    </converter>

    <managed-bean>
        <managed-bean-name>LifeCycleBean</managed-bean-name>
        <managed-bean-class>com.fsds.LifeCycleBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>

    <!-- our NumberBean we just created -->
    <managed-bean>
        <managed-bean-name>NumberBean</managed-bean-name>
        <managed-bean-class>tutorial.NumberBean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
        <managed-property>
            <property-name>min</property-name>
            <value>1</value>
        </managed-property>
        <managed-property>
            <property-name>max</property-name>
            <value>10</value>
        </managed-property>
    </managed-bean>

    <managed-bean>
        <managed-bean-name>PageUtil</managed-bean-name>
        <managed-bean-class>com.fsds.util.PageUtil</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>

    <managed-bean>
        <managed-bean-name>DebtorController</managed-bean-name>
        
<managed-bean-class>com.fsds.debtor.DebtorController</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>

    <!-- going from guess.xhtml to response.xhtml -->
    <navigation-rule>
        <from-view-id>/number/guess.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/number/response.xhtml</to-view-id>
            <redirect/>
        </navigation-case>
    </navigation-rule>

    <!-- going from response.xhtml to guess.xhtml -->
    <navigation-rule>
        <from-view-id>/number/response.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/number/guess.xhtml</to-view-id>
            <redirect/>
        </navigation-case>
    </navigation-rule>

    <navigation-rule>
        <from-view-id>/template/menu.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>main</from-outcome>
            <to-view-id>/main.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

    <navigation-rule>
        <description>Debtor Page List navigation rule</description>
        <from-view-id>/debtor/debtor.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>create</from-outcome>
            <to-view-id>/debtor/debtor-create.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>update</from-outcome>
            <to-view-id>/debtor/debtor-update.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

    <navigation-rule>
        <description>Create Debtor Page navigation rule</description>
        <from-view-id>/debtor/debtor-create.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/debtor/debtor-update.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>error</from-outcome>
            <to-view-id>/debtor/debtor-create.xhtml</to-view-id>
        </navigation-case>
         <navigation-case>
            <from-outcome>discard</from-outcome>
            <to-view-id>/debtor/debtor.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

    <navigation-rule>
        <description>Update Debtor Page navigation rule</description>
        <from-view-id>/debtor/debtor-update.xhtml</from-view-id>
        <navigation-case>
            <from-action>#{DebtorController.updateDebtor}</from-action>
            <from-outcome>success</from-outcome>
            <to-view-id>/debtor/debtor-update.xhtml</to-view-id>
        </navigation-case>
         <navigation-case>
            <from-outcome>discard</from-outcome>
            <to-view-id>/debtor/debtor.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

    <navigation-rule>
        <from-view-id>*</from-view-id>
        <navigation-case>
            <from-outcome>indexPage</from-outcome>
            <to-view-id>/index.xhtml</to-view-id>
            <redirect/>
        </navigation-case>
    </navigation-rule>

</faces-config>




--

Anthony Hong

Reply via email to