migrating to facelets 2.0 from facelets 1.x

与世无争的帅哥 提交于 2020-01-16 12:04:08

问题


I'm building a web App using JSF 2.0 and had a jaf-facelets.1.1.10 jar in my WEB-INF > lib folder, so now I'm trying to remove that so I can use the built int facelets 2.0 I was reading through this Question which balusC answered and I've done that, except teh part where it saysI need to replace FaceletViewHandler by ViewHandlerWrapper. for that I saw this question, but I don't have any faceletViewhandler classes in my project.

as of now, my webxml looks like this ( please check taht I didn't miss anything, or I'm referencing something I shouldn't:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>miloWeb</display-name>
  <welcome-file-list>
    <welcome-file>faces/pages/index.xhtml</welcome-file>
  </welcome-file-list>
  <listener>
    <listener-class>com.bravo.listeners.ServletListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
  <servlet>
        <servlet-name>PdfServlet</servlet-name>
        <servlet-class>com.bravo.servlets.PdfServlet</servlet-class>
    </servlet>    
    <servlet-mapping>
        <servlet-name>PdfServlet</servlet-name>
        <url-pattern>/PdfServlet</url-pattern>
    </servlet-mapping>
  <filter>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
  </filter> 
  <filter-mapping>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <servlet-name>Faces Servlet</servlet-name> 
  </filter-mapping>
  <context-param>
    <description>
      This is to Have separated faces.config files            
    </description>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>
      /pages/history/faces-config.xml,
      /pages/contactInformation/faces-config.xml,
      /pages/childHealthRecord/faces-config.xml,
      /pages/dashboard/faces-config.xml,
      /pages/insurance/faces-config.xml,
      /pages/search/faces-config.xml,
      /pages/labs/faces-config.xml,
      /pages/patient/faces-config.xml,
      /pages/physical/faces-config.xml,
      /pages/notes/faces-config.xml,
      /pages/scheduler/faces-config.xml,
      /pages/settings/faces-config.xml,
      /pages/orderEntry/faces-config.xml,
      /pages/vitals/faces-config.xml
    </param-value>
  </context-param>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
</web-app>

And as you can see, I have quite a few faces-configs I removed the

<application>
        <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
    </application>

And now it looks like this ( I know some features I don't need like the navigation, but does it really hurt to keep it taht way?):

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

<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">

    <managed-bean>
        <managed-bean-name>vitalsBB</managed-bean-name>
        <managed-bean-class>com.bravo.vitals.VitalsBB</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <navigation-case>
            <from-outcome>vitals</from-outcome>     
            <to-view-id>/pages/vitals/vitals.xhtml</to-view-id>
            <redirect />
        </navigation-case>
    </navigation-rule>

</faces-config>

after doing some changes and leaving it like that, I run the project on tomcatv7 and get this error:

java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
    com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:452)
    com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
    org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349)

Does that look like an error I would get for having my files like this? because all I did was remove the jar-facelets.1.1.10.jar and now I'm getting this Error. But teh App works fine b4 I remove the facelets jar, so what is the relationship between these two jars??

I tried adding the jstl.jar but that doesn't work, it just shows me this:


回答1:


The error suggest include jstl-1.2.jar available here in the same folder where your jsf jars are.

There is no need for facelets 2.0 jar, because JSF 2.0 adopted facelets as its default View Declaration Language (VDL), and now it is bundled inside jsf jars (for both MyFaces and Mojarra)




回答2:


To solve this issue, I had to Add the jstl-impl.jar and jstl-api.jar and update to the latest jsf-impl.jar and jsf-api.jar. That fixed it.

Don't really know why it never complained about it when the facelets.1.10.jar was there.



来源:https://stackoverflow.com/questions/9998524/migrating-to-facelets-2-0-from-facelets-1-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!