JSF - Não exibe valores setados

2 respostas
R

Olá Pessoal,
um comportamento estranho tem ocorrido na minha aplicação de teste no JSF ao seguir o tutorial básico aqui do GUJ.

O problema é que ao mostrar a página com os resultados dos campos ele exibe tudo e não o valor que deveria aparecer. Assim, ao invés de aparecer os campos como por exemplo Regis, Rua Teodomiro, Porto Alegre, 81367687 ele está exibindo o seguinte

buscar.jsp

Resultado da Busca

Nome:	 #{agenda.nome}

Endereço:	 #{agenda.endereco}

Cidade:	 #{agenda.cidade}

Telefone:	 #{agenda.telefone}

voltar

Ou seja, parece que ele está interpretando como texto e não como um jsf como deveria. Muito estranho.

Se alguem puder ajudar eu agradeço.

Att,
Regis

2 Respostas

Tiburcio_Mancha

posta sua página e seu MB!

R

Olá Tiburcio_Mancha,

a página é:

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
<body>
<f:view>
<h:form>
<center><h2> Busca </h2></center>
<br>
Digite o nome:
<h:inputText id="nome" value="#{agenda.nome}"/>
<h:commandButton value="OK" action="#{agenda.buscar}"/>
</h:form>
<br>
<h:outputLink value="index.jsf">
<f:verbatim>voltar</f:verbatim>
</h:outputLink>
</f:view>
</body>
</html>

O faces-config é:

<?xml version='1.0' encoding='UTF-8'?>
<!--
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 # 
 # Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
 # 
 # The contents of this file are subject to the terms of either the GNU
 # General Public License Version 2 only ("GPL") or the Common Development
 # and Distribution License("CDDL") (collectively, the "License").  You
 # may not use this file except in compliance with the License. You can obtain
 # a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
 # or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
 # language governing permissions and limitations under the License.
 # 
 # When distributing the software, include this License Header Notice in each
 # file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
 # Sun designates this particular file as subject to the "Classpath" exception
 # as provided by Sun in the GPL Version 2 section of the License file that
 # accompanied this code.  If applicable, add the following below the License
 # Header, with the fields enclosed by brackets [] replaced by your own
 # identifying information: "Portions Copyrighted [year]
 # [name of copyright owner]"
 # 
 # Contributor(s):
 # 
 # If you wish your version of this file to be governed by only the CDDL or
 # only the GPL Version 2, indicate your decision by adding "[Contributor]
 # elects to include this software in this distribution under the [CDDL or GPL
 # Version 2] license."  If you don't indicate a single choice of license, a
 # recipient has the option to distribute your version of this file under
 # either the CDDL, the GPL Version 2 or to extend the choice of license to
 # its licensees as provided above.  However, if you add GPL Version 2 code
 # and therefore, elected the GPL Version 2 license, then the option applies
 # only if the new code is made subject to such option by the copyright
 # holder.

-->

<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">

<navigation-rule>
	<from-view-id>/buscar.jsp</from-view-id>
	
	<navigation-case>
		<from-outcome>success</from-outcome>
		<to-view-id>/sucesso_busca.jsp</to-view-id>
	</navigation-case>
	
	<navigation-case>
		<from-outcome>failure</from-outcome>
		<to-view-id>/falha_busca.jsp</to-view-id>
	</navigation-case>
</navigation-rule>

<navigation-rule>
	<from-view-id>/inserir.jsp</from-view-id>
	
	<navigation-case>
		<from-outcome>success</from-outcome>
		<to-view-id>/sucesso_insercao.jsp</to-view-id>
	</navigation-case>
	
	<navigation-case>
		<from-outcome>failure</from-outcome>
		<to-view-id>/falha_insercao.jsp</to-view-id>
	</navigation-case>
</navigation-rule>

<managed-bean>
	<managed-bean-name>agenda</managed-bean-name>
	<managed-bean-class>br.com.brasilveiculos.AgendaDB</managed-bean-class>
	<managed-bean-scope>session</managed-bean-scope>
</managed-bean>

</faces-config>

E o sucesso_busca é:

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
<body>
<f:view>
<h:form>
<center><h2> Resultado da Busca </h2></center>
<br>
<table>
<tr>
<td>Nome:</td>
<td>
<h:outputText value="#{agenda.nome}"/>
</td>
</tr>
<tr>
<td>Endereço:</td>
<td>
<h:outputText value="#{agenda.endereco}"/>
</td>
</tr>
<tr>
<td>Cidade:</td>
<td>
<h:outputText value="#{agenda.cidade}"/>
</td>
</tr>
<tr>
<td>Telefone:</td>
<td>
<h:outputText value="#{agenda.telefone}"/>
</td>
</tr>
</table>
</h:form>
<br>
<h:outputLink value="index.jsf">
<f:verbatim>voltar</f:verbatim>
</h:outputLink>
</f:view>
</body>
</html>

Estou utilizando o mojarra-2.0.3-FCS-binary.zip colocando as apis jsf-api.jar e jsf-impl.jar em WEB-INF/lib do meu Dynamic Project no Eclipse.

Agradeço novamente pela atenção.

Att,
Regis

Criado 30 de dezembro de 2010
Ultima resposta 30 de dez. de 2010
Respostas 2
Participantes 2