Boa noite ou melhor, boa madrugada!
Estou a dois dias revisando meu código tentando achar o erro da minha aplicação, e não consigo visualizar…
Minha aplicação se trata de uma Biblioteca de DVD’s onde eu posso cadastrar Title, Genre, year…
Fiz todo o processo como manda o Figurino…rsrs
Mas tá brabo!!
Achei que fosse o meu "face-config.xml"
eu acho que não é…
eu vou colocar o ERROR primeiro, e logo as paginas de aplicação…
Sinto que bobeira, mas tão estou vendo, Peço aos amigos AJUDA!!
OBRIGADO!
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
org.apache.jasper.JasperException: /add_dvd.jsp(12,31) #{...} is not allowed in template text
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
Segue agora as paginas:
Index
Add_DVD
e
Sucesso… Vejam!
<!--INDEX.JSP-->
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<f:view>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title><h:outputText value="#{bundle.application_title}"/></title>
</head>
<body>
<h:form>
<h1><h:outputText value="#{bundle.application_title}"/></h1>
<ul>
<li>
<h:commandLink action="#{menuController.exibirAddDvd}">
<h:outputText value="#{bundle.label_add_dvd}"/>
</h:commandLink>
</li>
</ul>
</h:form>
</body>
</f:view>
<!--ADD_DVD.JSP-->
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title><h:outputText value="#{bundle.label_add_dvd }"/></title>
</head>
<body>
<f:view>
<h:form>
<table>
<tr>
<th><h:outputText value="#{bundle.label_titulo}"/>:</th>
<td><h:inputText id="title" value="#{dvdController.dvdItem.title }" required="true" requiredMessage="#{bundle.error_title_required }"/></td>
<td><h:message for="title" style="color: red;"/></td>
</tr>
<tr>
<th><h:outputText value="#{bundle.label_ano}"/>:</th>
<td>
<h:inputText id="year" value="#{dvdController.dvdItem.year }" required="true" requiredMessage="#{bundle.error_year_required}" validatorMessage="#{bundle.error_year_invalid }" maxlength="4">
<f:convertNumber integerOnly="true"/>
</h:inputText>
</td>
<td>
<h:message for="year" style="color:red;"/>
</td>
</tr>
<tr>
<th><h:outputText value="#{bundle.label_genero}"/></th>
<td>
<h:selectOneMenu id="genre" value="#{dvdController.dvdItem.genre}" required="true" requiredMessage="#{bundle.error_genre_required}">
<f:selectItem itemLabel=" " itemValue=" "/>
<f:selectItem itemLabel="#{bundle.label_genero_scfi}" itemValue="#{bundle.label_genero_scfi}"/>
<f:selectItem itemLabel="#{bundle.label_genero_drama}" itemValue="#{bundle.label_genero_drama}"/>
<f:selectItem itemLabel="#{bundle.label_genero_comedia}" itemValue="#{bundle.label_genero_comedia }"/>
</h:selectOneMenu>
</td>
<td><h:message for="genre" style="color:red;"/></td>
</tr>
<tr>
<th><h:outputText value="#{bundle.label_novo_genero}"/>:</th>
<td>
<h:inputText id="newGenre" value="#{dvdController.novoGenero}"/>
</td>
</tr>
</table>
<br />
<!-- INCLUIR DVD -->
<h:commandButton id="incluirDvd" action="#{dvdController.incluir}" value="#{bundle.label_add_dvd}"/>
<br/>
<!-- VOLTAR -->
<h:commandLink action="#{menuController.index}" immediate="true">
<h:outputText value="#{bundle.lable_voltar_pagina_inicial}"/>
</h:commandLink>
</h:form>
</f:view>
</body>
</html>
<!--SUCCESS.JSP-->
l version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>${bundle.application_title}</title>
</head>
<body>
<h:form>
<h1>
<h:outputText value="#{bundle.message_dvd_incluido}"/>
</h1>
<h:outputText value="#{bundle.message_info_dvd}"/>:
<br />
<h:outputText value="#{bundle.label_titulo}"/>:${dvdController.dvd.title}
<br />
<h:outputText value="#{bundle.label_ano}"/>:${dvdController.year}
<br />
<h:outputText value="#{bundle.label_genero}"/>:${dvdController.genre}
<br />
<br />
<h:commandLink action="#{menuController.index}">
<h:outputText value="#{bundle.lable_voltar_pagina_inicial}"/>
</h:commandLink>
</h:form>
</body>
</html>
Se AGORA OS CODIGOS WEB.XML E O FACE-CONFIG.XML
<!--WEB.XML-->
<?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>treinandoJSF</display-name>
<welcome-file-list>
<welcome-file>index.jsf</welcome-file>
</welcome-file-list>
<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>
</web-app>
<!--FACE-CONFIG.XML-->
<?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">
<application>
<!-- Definindo meu ResoucerBundle -->
<resource-bundle>
<base-name>messages</base-name>
<var>bundle</var>
</resource-bundle>
<message-bundle id="msg">messages</message-bundle>
<locale-config>
<default-locale>pt</default-locale>
<supported-locale>pt</supported-locale>
</locale-config>
</application>
<!-- MENU -->
<navigation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>exibirAddDvd</from-outcome>
<to-view-id>/add_dvd.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<!-- DVD -->
<navigation-rule>
<from-view-id>/add_dvd.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/success.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<!-- GLOBAL -->
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>index</from-outcome>
<to-view-id>/index.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<managed-bean-name>menuController</managed-bean-name>
<managed-bean-class>com.dvd.controller.MenuController</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>dvdController</managed-bean-name>
<managed-bean-class>com.dvd.controller.DvdController</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
</faces-config>
Agora as classes JAVA…
package com.dvd.controller;
import com.dvd.entity.DVDItem;
public class DvdController {
private String novoGenero;
private DVDItem dvdItem = new DVDItem();
/**
*
* Incluir Add DVD
* @ return String
*
* **/
public String incluir(){
if(this.novoGenero != null && this.novoGenero.length()>0){
dvdItem.setGenre(this.novoGenero);
}//end if
return"success";
}
public String getNovoGenero() {
return novoGenero;
}
public void setNovoGenero(String novoGenero) {
this.novoGenero = novoGenero;
}
public DVDItem getDvdItem() {
return dvdItem;
}
public void setDvdItem(DVDItem dvdItem) {
this.dvdItem = dvdItem;
}
}
// DO MESMO PACOTE...
package com.dvd.controller;
public class MenuController {
@SuppressWarnings("unused")
private static final long serialVersionUID = 1L;
/**
* Exibe tela pagina Inicial
* @return String
*
*/
public String index() {
return "index";
}
/**
* Exibe tela Add DVD
* @return String
*
*/
public String exibirAddDvd(){
return "exibirAddDvd";
}
}
<!--OUTRA CLASSE-->
package com.dvd.entity;
import java.io.Serializable;
public class DVDItem implements Serializable{
private static final long serialVersionUID= 1L;
private Integer id;
private String title;
private Integer year;
private String genre;
public boolean equals(Object o){
boolean valida= false;
if(o != null && o instanceof DVDItem){
DVDItem item = (DVDItem) o;
//verify title DVD
if(item.getTitle().equals(this.title)){
valida=true;
}
}
return valida;
}
public int hashCode(){
return this.title.length()^2;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Integer getYear() {
return year;
}
public void setYear(Integer year) {
this.year = year;
}
public String getGenre() {
return genre;
}
public void setGenre(String genre) {
this.genre = genre;
}
}
ESSE É O MEU ARQUIVO MESSAGE
#Labels
#====================================================
application_title=Biblioteca Virtual de DVD's
label_titulo=Título
label_ano=Ano
label_genero=Gênero
label_novo_genero=Novo Gêneroa
label_genero_scfi=Sci-fi
label_genero_drama=Drama
label_genero_comedia=Comedia
label_add_dvd=Adicionar DVD
label_list_dvd=Exibir Lista de DVD's
lable_voltar_pagina_inicial=Voltar para pagina Principal
#Messages
#====================================================
message_info_dvd=O seguinte DVD foi incluído
message_dvd_incluido=DVD incluído com sucesso
#Errors
#====================================================
error_title_required=Título é de preenchimento obrigatório
error_year_required=Ano é de preenchimento obrigatório
error_year_invalid=Ano é invalido
error_genre_required=Gênero é de preenchimento obrigatório
error_nao_esperado=Ocorreu um erro n\u00e3o esperado durante a execu\u00e7\u00e3o. Por favor entre em contato com o Adiministrador do Sistema.
AGRADECIDO FICO PELA AJUDA DE VOCÊS…
================================= Boa Madrugada!!!