Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Managedbean could not be create Can't set managed bean property

843842Nov 2 2006 — edited Nov 2 2006
I know that many people have had this issue in the past, well I have it now ,and I have tryed every solution I have found in the forums.
Some how I cannot get to create the managed bean.

I have used the myeclipse framework to create a simple example of JSF
I am using JDK 5
JBOSS 4
JSF Sun 1.1_01

here is the think I have two String properties that are inicialized by the user in a form, then in the next page I print another managed-bean.
When the app starts the container is supposed to create the bean from the faces-config. But I allways get:

13:28:37,657 ERROR [ApplicationImpl] Managedbean CentralBean could not be created Can't set managed bean property: 'cuantos'.
javax.faces.FacesException: Can't set managed bean property: 'cuantos'.


I have tryed to inicialize the property in the config file, but no matter what type I choose I allways get the same exception.
If I erase the property from the config file, then the form is displayed but at the next page I get a
 Unknown property 'cuantos'
Here is my faces-config.xml
<?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>CentralBean</managed-bean-name>
		<managed-bean-class>org.invias.bean.CentralBean</managed-bean-class>
		<managed-bean-scope>session</managed-bean-scope>
		<managed-property>
			<property-name>user</property-name>
			<property-class>java.lang.String</property-class>
			<null-value></null-value>
		</managed-property>
		<managed-property>
			<property-name>password</property-name>
			<property-class>java.lang.String</property-class>
			<value></value>
		</managed-property>
		<managed-property>
			<property-name>cuantos</property-name>
			<value>1</value>
		</managed-property>
	</managed-bean>
here is my java code:
public final class CentralBean extends Object implements Serializable{

	 /**
	 * 
	 */
	private static final long serialVersionUID = 151531L;

	private Proceso procesos;
	
	 private Integer cuantos;
	/**
	 * 
	 */
	 private String password = new String();
	/**
	 * 
	 */
	 private String user = new String();
....

public String loginUser() {
		System.out.println("loginuser");
		//conecto con los beans.
//			InitialContext ctx = new InitialContext();
//			Object objref = ctx.lookup("ejb/Central");
//			org.invias.ejb.CentralBean SessionBean = (org.invias.ejb.CentralBean) PortableRemoteObject.narrow(objref, CentralHome.class);
//			SessionBean.setNombre(getUser());
//			es = SessionBean.getText();
			FacesContext facesContext = FacesContext.getCurrentInstance();
			FacesMessage facesMessage = new FacesMessage("Nuevo Mensaje");    	   	
			
			facesContext.addMessage("loginForm", facesMessage);
			
			if("dani".equals(getUser()) && "myeclipse".equals(getPassword())){
				procesos = new Proceso();
				cuantos = new Integer(1);
				return "success";
			}
				
			return "failure";
	}
.....
public Integer getCuantos() {
		
		return cuantos;
	}
	
	public void setCuantos(Integer cuan){
		this.cuantos=cuan;
	}
	/**
	 * @param cuantos
	 */
	public void setCuantos(int cuan) {
		System.out.println("setCuantos");
		this.cuantos = new Integer(cuan);
	}
	
	/*
	 *  (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString(){
		return "";
	}
}
fairly simple....

This is the first page, that is supposed to recieve the user, get his user and password, and then proceed to display his info.
Here is my login.jsp:
	<f:view>

		<f:loadBundle basename="org.invias.MessageBundle" var="bundle" />
		 Login Page<br>
		 <h:form id="loginForm" rendered="true">
					<h:outputLabel rendered="true" for="user" value="#{bundle.user_label}"/>

					<h:inputText value="#{CentralBean.user}" rendered="true" required="true" id="user" />

					<P><h:outputLabel rendered="true" for="password" value="#{bundle.password_label}" />
					<h:inputSecret value="#{CentralBean.password}" rendered="true" required="false" redisplay="false" id="password" /><BR>
					<h:commandButton value="#{bundle.login_button}" rendered="true" action="#{CentralBean.loginUser}" id="submit" />


				</P></h:form></f:view>
Once I have user and password, I will look in a DB for the user info, for now I am trying to print some dummy data, but...
here is my code:
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<base href="<%=basePath%>">

	<title>My JSF 'Central.jsp' starting page</title>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
</head>
  
<body>
	<f:view>
		<f:loadBundle basename="org.invias.MessageBundle" var="bundle" /> <br>
		 Bienvenido <h:outputLabel value="#{CentralBean.user}" rendered="true" for="user" />
		<P>
</P><P>Usted tiene los siguinetes procesos: <h:outputText rendered="true" value="#{CentralBean.cuantos}" /></P>
<h:dataTable id="table" var="row" value="#{CentralBean.procesos}" binding="#{CentralBean.procesos}" border="1" rendered="true">
 <h:column>
 	<h:outputText value="#{row.tipo}" />
 </h:column>
</h:dataTable>

		<h:form id="ProcesoForm" rendered="true">
			id <h:inputText rendered="true" required="false" id="name" />
			<h:commandButton value="Crear" rendered="true" id="submit" action="#{Central.ingresarProceso}" />

		</h:form></f:view>
	</body>
</html>
I have used the guide in a step by step manner, it worked well, but when I tryed to extend the example it failed. I have no idea why.
I all ready have a book about JSF, and according to the book my faces-config is ok, and my java code is working... So I am missing something, please help me find out, I have lost two days in this simple problem.

Thanks for the help

Daniel Castro
Any more info will be gandly given, and I will surely post the solution once I figure it out.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 30 2006
Added on Nov 2 2006
1 comment
773 views