Pra quem manja de JSF + Facelets

2 respostas
Sparcx86

Estou tentando subir um exemplo de JSF e facelets bem simples, aquele famoso number guest da Sun.
Mas na hora do deploy no weblogic ele dá este estranho erro:

Can't instantiate class: 'com.sun.facelets.FaceletViewHandler'

Não sei o que pode ser, procurei no google a respeito mas não conclui nada até agora.

Abaixo meu web.xml e faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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>jsffacelets</display-name>
    <context-param>
        <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
        <param-value>resources.application</param-value>
    </context-param>
   	
	<context-param>
		<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
		<param-value>.xhtml</param-value>
	</context-param>
    
    <listener>
        <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>
    <servlet>
        <!--Standard Action Servlet Configuration (with debugging)-->
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
            <param-name>config</param-name>
            <param-value>/WEB-INF/config/struts-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>debug</param-name>
            <param-value>2</param-value>
        </init-param>
        <init-param>
            <param-name>detail</param-name>
            <param-value>2</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>faces</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <!--Standard Action Servlet Mapping-->
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>faces</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>faces</servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.jsf</welcome-file>
        <welcome-file>index.faces</welcome-file>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
</web-app>
<?xml version='1.0' encoding='UTF-8'?>

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

<faces-config>
			
  <!-- from project setup -->
  <application>
    <view-handler>
      com.sun.facelets.FaceletViewHandler
    </view-handler>    
  </application>
  
  <!-- our NumberBean we created before -->
  <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>
  
  <!-- going from guess.xhtml to response.xhtml -->
  <navigation-rule>
    <from-view-id>/guess.xhtml</from-view-id>
    <navigation-case>
      <from-outcome>success</from-outcome>
      <to-view-id>/response.xhtml</to-view-id>
    </navigation-case>
  </navigation-rule>

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

</faces-config>

Abraços.

2 Respostas

Sparcx86

Desisti! Isso não roda nem a pau no meu ambiente (weblogic 10)
Vou tentar a dupla JSF + Tiles que parece ser mais viável!

Valeu

contrabando

Velhinho…

você está tentando misturar JSF e Struts???

&lt;listener&gt;  
         &lt;listener-class&gt;com.sun.faces.config.ConfigureListener&lt;/listener-class&gt;  
     &lt;/listener&gt;  
     &lt;servlet&gt;  
         &lt;!--Standard Action Servlet Configuration (with debugging)--&gt;  
         &lt;servlet-name&gt;action&lt;/servlet-name&gt;  
         &lt;servlet-class&gt;org.apache.struts.action.ActionServlet&lt;/servlet-class&gt;  
         &lt;init-param&gt;  
             &lt;param-name&gt;config&lt;/param-name&gt;  
             &lt;param-value&gt;/WEB-INF/config/struts-config.xml&lt;/param-value&gt;  
         &lt;/init-param&gt;  
         &lt;init-param&gt;  
             &lt;param-name&gt;debug&lt;/param-name&gt;  
             &lt;param-value&gt;2&lt;/param-value&gt;  
         &lt;/init-param&gt;  
         &lt;init-param&gt;  
             &lt;param-name&gt;detail&lt;/param-name&gt;  
             &lt;param-value&gt;2&lt;/param-value&gt;  
         &lt;/init-param&gt;  
         &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;  
     &lt;/servlet&gt;

“faz isso não”
se estás fazendo testes, faz funcionar primeiro o JSF, depois se ainda precisar(muito, mas, muito mesmo) ai você implementa com Struts :lol:

Criado 24 de novembro de 2008
Ultima resposta 25 de nov. de 2008
Respostas 2
Participantes 2