struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ganesh g <ganeshstr...@yahoo.com>
Subject Problem of ClassCastException when ArrayList to My own Class
Date Thu, 22 Apr 2004 07:22:24 GMT
Hi Friends,
ThanQ very much 4ur non-stop help towards me.
Here is a problem with Typecasting,throws ClassCastException.
I'm not able get why it's getting.Bcoz i spent on this problem around 2weeks.
i'm very thankful to u for ur solution.
 
Problem of Area is as Follows:
 
i've myown class called "FileProperties"
 
Step:1
 
public class FileProperties
{
  private long fileSize;
  private Date fileDate;
  private String filename;
  private String filepath;
  private String clientid;
...................................some other properties..........

  public FileProperties()
  {
  }
  public String getFilename()
  {
  return filename;
  }
  public void setFilename(String filename)
  {
  this.filename = filename;
  }

  public String getFilepath()
  {
  return filepath;
  }
  public void setFilepath(String filepath)
  {
   this.filepath = filepath;
  }
...................some other getter/setter methods.........
}

Step:2
 
In actionForm called mtActionForm i declared as follows:
 
public class MtActionForm extends ActionForm
{
private FileProperties singleFile;
private Collection mtJobsList=new ArrayList();
...................................some other properties..........

  public Collection getMtJobsList() {
  return mtJobsList;
  }
  public void setMtJobsList(Collection mtJobsList) {
  this.mtJobsList = mtJobsList;
  }
  public FileProperties getSingleFile()
  {
    return singleFile;
  }
  public void setSingleFile(FileProperties singleFile)
  {
    this.singleFile = singleFile;
  }

 

}
Now i'm showing u exact problem of Area
 
Step:3
 
MtActionForm mtForm = (MtActionForm)actionForm;
String tempStr = httpServletRequest.getParameter("fileIndex");
int index = Integer.parseInt(tempStr);
ArrayList aList = (ArrayList)mtForm.getMtJobsList();//No exception Here
 
FileProperties sFile =(FileProperties )aList.get(index);//This is where 
ClassCastException thrown
 
mtForm.setSingleFile(sFile);

Step:4
 
In Jsp i'm going to use as follows
 
<bean:write name="mtActionForm" property="singleFile.filename"/>
 
I'm eagerly awaiting your reply as soon as possible.
 
Thanks & Regards
Ganesh
 

		
---------------------------------
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message