Ajuda em HelloWorld JSF

6 respostas
cris.t

Olá.
Estou tentando fazer um helloWorld com JSF, porém não estou conseguindo rodar, não está dando nehuma exception, apenas tem um Werning na compilação do tomcat dizendo:
WARNING: JSF1059: WARNING! The com.sun.faces.verifyObjects feature is to aid developers not using tools. It shouldn’'t be enabled if using an IDE, or if this application is being deployed for production as it will impact application start times.

segue código abaixo:

web.xml

<context-param>
    <param-name>com.sun.faces.verifyObjects</param-name>
    <param-value>true</param-value>
</context-param>

<context-param>
    <param-name>com.sun.faces.validateXml</param-name>
    <param-value>true</param-value>
</context-param>

<context-param>	
   <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
   <param-value>client</param-value>
</context-param>
  
<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>*.jsf</url-pattern>   
</servlet-mapping>

faces-config:

<managed-bean>
                <managed-bean-name>hwBean</managed-bean-name>
 	<managed-bean-class>br.com.jsftutorial.HelloWorldBean</managed-bean-class>
	<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
	
<navigation-rule>
	<navigation-case>
		<from-outcome>sucesso</from-outcome>
		<to-view-id>/resultado.jsp</to-view-id>
	</navigation-case>
</navigation-rule>

index.jsp

<f:view>
		<h:form id="formulario">
			<b>Nome:</b>
			<h:inputText id="nome" value="#{hwBean.nome}" required="true" requiredMessage="O campo deve ser preenchido"></h:inputText>
			<h:commandButton value="GO" action="#{hwBean.acao}" />
			<h:message for="nome" errorStyle="color:red" />
		</h:form>
	
	</f:view>

resultado.jsp

<f:view>
	Ola, <h:outputText value="#{hwBean.nome}" />!
  </f:view>

HelloWorldBean.java

private String nome;
	
	public HelloWorldBean() {}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String acao() {
		return "sucesso";
	}

Valew!

6 Respostas

hudson.negao

tente ler a mensagem de erro e retirar essas linhas

<context-param> <param-name>com.sun.faces.verifyObjects</param-name> <param-value>true</param-value> </context-param>

cris.t

Ok. Obrigada.
parou de dar o Warning, agora está a segunte exception:

java.lang.RuntimeException: Cannot find FacesContext
	at javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1855)
	at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1672)
	at org.apache.jsp.index_jsp._jspx_meth_f_005fview_005f0(index_jsp.java:109)
	at org.apache.jsp.index_jsp._jspService(index_jsp.java:82)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
hudson.negao

qual implementação do jsf esta utilizando?

cris.t

esta versão: 1.2_11-b01

Lavieri

o cara.... tenta ver esses video aqui

http://www.thiagochaves.eti.br/wordpress/?p=54
http://www.thiagochaves.eti.br/wordpress/?p=55
http://www.thiagochaves.eti.br/wordpress/?p=56

são 3 video aulas, ensinando a fazer um applicativo com JSF, não tem erro ...

Logo na 1° aula, tem la pra baixar esse arquivo aqui

http://www.thiagochaves.eti.br/videoaulas/lib.rar

com todas as bibliotecas que vc vai precisar pro aplicativo, usa hibernate tb, e ele fala uma manha pra por o JSF pra funfar

ele fala pra vc adcionar 3 bibliotecas logo quando configura o JSF
jstl-1.2.jar
jsf-api-1.2.jar
jsf-impl-1.2.jar

........ a configuração do meu web.xml ficou assim

<?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_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>SysMatricula</display-name>
  <welcome-file-list>
    <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>
  
  <!-- Define a skin do rich faces.  varias opções -->
  <context-param>
    <param-name>org.richfaces.SKIN</param-name>
    <!--<param-value>DEFAULT</param-value>-->
  	<!--<param-value>plain</param-value>-->
  	<!--<param-value>emaraldTown</param-value>-->
  	<!--<param-value>blueSky</param-value>-->
  	<!--<param-value>wine</param-value>-->
  	<!--<param-value>japaCherry</param-value>-->
  	<!--<param-value>ruby</param-value>-->
  	<!--<param-value>classic</param-value>-->
  	<param-value>deepMarine</param-value>
  </context-param>
  
  <!-- Configura onde vai salvar os estados do componente -->
  <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
  </context-param>
  
  <!-- Configura o filtro obrigatorio do Ajax4jsf -->
  <filter>
  	<display-name>Ajax4jsf Filter</display-name>
  	<filter-name>ajax4jsf</filter-name>
  	<filter-class>org.ajax4jsf.Filter</filter-class>
  </filter>
  <filter-mapping>
  	<filter-name>ajax4jsf</filter-name>
  	<servlet-name>Faces Servlet</servlet-name>
  	<dispatcher>REQUEST</dispatcher>
  	<dispatcher>FORWARD</dispatcher>
  	<dispatcher>INCLUDE</dispatcher>
  </filter-mapping>
  
  
  
  <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>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
</web-app>

[size=18][color=red]ahhh o mais importante!!!!
a 1° video aula, não funciona com os Codecs comuns, vc tem que baixar K-Lite CODEC
[/color][/size]
http://baixaki.ig.com.br/download/K-Lite-Codec-Pack-Full.htm

cris.t

VAlew pela dica lavieri, vou dar uma olhada nesses vídeos…pois o meu aqui num funfa msm…

Criado 7 de janeiro de 2009
Ultima resposta 8 de jan. de 2009
Respostas 6
Participantes 3