users@javaserverfaces.java.net

Arraylist in Bean can't display in jsp

From: jayachandra_m <jayachandra_m_at_persistent.co.in>
Date: Tue, 8 Apr 2008 03:03:33 -0700 (PDT)

i have bean name "Database.java" with arraylist, i want to display the
contents in the arraylist in one of my jsp i.e "ep.jsp". can anybody help
me what is the wrong i am doing.

Database.java
public class Database {
         List al=new ArrayList();
        public List calToDatabase;
        private String loginname=null;
        private String password=null;
 
        public String temporaryMethos()
                {
                        System.out.println("Contents in the List#########");
                        
                        al.add("jaya");
                        al.add("chandra");
                        al.add("raheem");
                        al.add("balu");
                        System.out.println("Contents in the List"+al);
                        Database db= new Database();
                        db.setCalToDatabase(al);
 
                return "success";
        }
 
 
public String temporary()
                {
                        System.out.println("@@@@@@@@@@@@@ in the jupimg");
                        
                        return "jump";
                }
 
        
        public String getLoginname() {
                return loginname;
        }
        public void setLoginname(String loginname) {
                this.loginname = loginname;
        }
        public String getPassword() {
                return password;
        }
        public void setPassword(String password) {
                this.password = password;
        }
        public List getCalToDatabase() {
                return calToDatabase;
        }
 
        public void setCalToDatabase(List calToDatabase) {
                this.calToDatabase = calToDatabase;
                System.out.println("This is at Setter"+calToDatabase);
        }
                        
}

faces-config.xml
<?xml version="1.0"?>
<!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>Database</managed-bean-name>
        
<managed-bean-class>com.persistent.parashar.database.Database</managed-bean-class>
                <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
        <navigation-rule>
                <from-view-id>/jsp/login.jsp</from-view-id>
                <navigation-case>
                        <from-action>#{Database.temporaryMethos}</from-action>
                        <from-outcome>success</from-outcome>
                        <to-view-id>/jsp/resultforsuccess.jsp</to-view-id>
                </navigation-case>
                    <navigation-case>
                        <from-action>#{Database.temporaryMethos}</from-action>
                        <from-outcome>fail</from-outcome>
                        <to-view-id>/jsp/resultforfail.jsp</to-view-id>
                    </navigation-case>
        </navigation-rule>
 
         <navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
        <from-action>#{Database.temporary}</from-action>
      <from-outcome>jump</from-outcome>
          <to-view-id>/jsp/ep.jsp</to-view-id>
    </navigation-case>
        </navigation-rule>
 
</faces-config>

ep.jsp
<%@ page contentType="text/html"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
this is experiment only
<f:view>
<html>
<head><title>JSF Simple Login Example</title></head>

<body>
<h:dataTable id="dbtable" value="#{Database.calToDatabase}" var="ll"> //
List in database class
<h:column>
<f:facet name="header">
</f:facet>
<h:outputText value="#{ll}" id="dbname" />// List in database class

</h:column>
</h:dataTable>

</body>
</html>
</f:view>
-- 
View this message in context: http://www.nabble.com/Arraylist-in-Bean-can%27t-display-in-jsp-tp16554804p16554804.html
Sent from the javaserverfaces users mailing list archive at Nabble.com.