I ran into a runtime ClassCastException to retrieve
data from a <h:dataTable ... > after clicking on the
button of that web page.

Here is that web page xxx.jsp:
<h:dataTable value="#{arrival.personnel}" var="pInfo">
......
......
<h:commandButton id="Depart" value="DEPART"
action="#{departure.updateDeparturePersonnel}"/>


The "personnel" is the List that builds the xxx.jsp
and it is also the List I try to access after the
button in the xxx.jsp is clicked. Here in my
configuration file:

 <managed-bean>
  <managed-bean-name>arrival</managed-bean-name>
 
<managed-bean-class>processAction.DepartureManagementBean</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
 </managed-bean>
 <managed-bean>
  <managed-bean-name>departure</managed-bean-name>
 
<managed-bean-class>processAction.DepartureManagementBean</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
 </managed-bean>


when the updateDeparturePersonnel() method is called
in the DepartureManagementBean.java, I got run-time
ClassCastException. And I am unable to see the
problems in my code.

quote:

java.lang.ClassCastException
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
javax.faces.component.UICommand.broadcast(UICommand.java:312)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)

This is my DepartureManagementBean.java:

package processAction;
 
import java.util.ArrayList;
import java.util.List;
 
import processDelegate.ListPersonnel;
import processDelegate.PersonnelBean;
 
public class DepartureManagementBean 
{
    private List personnel = new ArrayList();
    private List departurePersonnel = new ArrayList();
    
    // The constructor part and the creation of the
"personnel" List has been successfully tested
    public DepartureManagementBean()
    {
   
        // instantiate the business delegate
        ListPersonnel listPersonnel = new ListPersonnel();
        personnel = listPersonnel.getPersonnelInfo();
 
    }
        public List getPersonnel() 
        {
                return personnel;
        }
        public void setPersonnel( List personnel ) 
        {
                this.personnel = personnel;
        }
 
        public List updateDeparturePersonnel( ) 
        {
        // Iterate through the data rows ...
        for ( int index = 0; index < personnel.size();
index++ ) 
        {
            PersonnelBean personnelBean = new
PersonnelBean();
                personnelBean = ( PersonnelBean
)personnel.get(index);
         
                    // If this row is selected, add all data
fields the corresponding message
                    if ( personnelBean.isSelectedPersonnel()
)
                    {
                        departurePersonnel.add( personnelBean
);
                    }
        }
        return departurePersonnel;
    }
        
    public List getDeparturePersonnel() 
    {
      return departurePersonnel;
    }
    public void setDeparturePersonnel( List
departurePersonnel ) 
    {
      this.departurePersonnel = departurePersonnel;
    }
        
}// End DepartureManagementBean.java
 



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to