O "pobrema" é o seguinte:
Estava fazendo um CRUD em casa quando eu me deparei com uma situação um tanto capiciosa, quando eu utilizo o atributo rendered do componente para mostrá-lo ou não na tela ele não popula o atributo do meu MBean, se eu retirar esse "controle" ele funciona normalmente sem maiores problemas.
Ele só funciona quando o MBean está no escopo session (o que eu quero evitar)
Estou utilizando o Myfaces 1.1.6 e o tomcat 5.0, vou tentar atualizar a versão do Myfaces para ver se é um Bug
Seguem os "fontes"
import java.util.Random;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
public class TesteMBean {
private Integer id;
private String text;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String save() {
id = new Random().nextInt();
return null;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
}
<%@ 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"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<f:view>
<h:form>
<h:outputText value="id" rendered="#{testeMBean.id != null}"></h:outputText>
<h:inputText value="#{testeMBean.id}"
rendered="#{testeMBean.id != null}" />
<br />
<h:inputText value="#{testeMBean.text}" />
<h:commandButton action="#{testeMBean.save}" />
</h:form>
</f:view>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
<managed-bean>
<managed-bean-name>testeMBean</managed-bean-name>
<managed-bean-class>TesteMBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
</faces-config>
