Olá, todos,
Estou com um problema para passar um parâmetro para o managerbean.
Sou novo em JSF e web, então segue o código e se alguém puder ajudar.
O erro que está ocorrendo é o seguinte:
javax.faces.FacesException: javax.faces.FacesException:
The scope of the referenced object: #{param.id2} is shorter than the referring object
Manager bean
package bean;
import sintev.presentation.ctr.SintevCTRFacade;
import sintev.business.to.Uf;
//import javax.faces.event.ValueChangeEvent;
//import javax.faces.model.SelectItem;
import java.util.*;
import java.util.ArrayList;
//import java.lang.*;
import javax.faces.context.FacesContext;
public class RelatorioUfBean {
private Uf uf = new Uf();
private List<Uf> listaUfs = new ArrayList<Uf>();
private SintevCTRFacade sintevCTRFacade = new SintevCTRFacade();
/** Creates a new instance of RelatorioUf */
public RelatorioUfBean() {
this.atualizaLista();
}
public void atualizaLista(){
// ArrayList<Uf>aaa = new ArrayList<Uf>();
//setSintevCTRFacade(new SintevCTRFacade());
this.setListaUfs(getSintevCTRFacade().getUfsGrid());
}
public void excluir(){
sintevCTRFacade.excludeUf((String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id2"));
}
public Uf getUf() {
return uf;
}
public void setUf(Uf uf) {
this.uf = uf;
}
public List<Uf> getListaUfs() {
return listaUfs;
}
public void setListaUfs(List<Uf> listaUfs) {
this.listaUfs = listaUfs;
}
public SintevCTRFacade getSintevCTRFacade() {
return sintevCTRFacade;
}
public void setSintevCTRFacade(SintevCTRFacade sintevCTRFacade) {
this.sintevCTRFacade = sintevCTRFacade;
}
}
JSP
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Relatório de UF</title>
</head>
<body>
<f:view>
<h:form>
<table border="1">
<tr>Relatório de UF's</tr>
<tr>
<td>UF</td>
<td>Denominação UF</td>
<td>Icms UF</td>
</tr>
<c:forEach var="varUf" items="#{RelatorioUfBean.listaUfs}">
<tr>
<td>
<h:outputText value="#{varUf.idUf}"/>
</td>
<td>
<h:outputText value="#{varUf.denUf}"/>
</td>
<td>
<h:outputText value="#{varUf.icmsUf}"/>
</td>
<td>
<h:commandLink action="#{RelatorioUfBean.excluir}" value="Excluir">
<f:param name="#{id2}" value="#{varUf.idUf}"/>
</h:commandLink>
</td>
</tr>
</c:forEach>
</table>
</h:form>
</f:view>
</body>
</html>
faces-config
<faces-config version="1.2"
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_1_2.xsd">
<managed-bean>
<managed-bean-name>CadastroUfBean</managed-bean-name>
<managed-bean-class>bean.CadastroUfBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>id</property-name>
<property-class>java.lang.String</property-class>
<value>id</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>RelatorioUfBean</managed-bean-name>
<managed-bean-class>bean.RelatorioUfBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>id2</property-name>
<property-class>java.lang.String</property-class>
<value>#{param.id2}</value>
</managed-property>
</managed-bean>
<navigation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>case1</from-outcome>
<to-view-id>/CadastroUf.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>case2</from-outcome>
<to-view-id>/relatorioUf.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
Obrigado,
Adauto.