I am having a problem with Interface. The Interface looks like this.
---------
package packageName;
import java.util.*;
public interface dateIntFace {
public int getCDate();
public
String getYr();
public Vector getMDates();
}
-----------
I have a class "dateClss" which implements this interface. It has setter functions also in addition to the getter functions of the interface.
package packageName;
import java.util.Vector;
public class Dateclss implements dateIntFace {
private int cDate;
private String yr;
private Vector m_dates = new Vector();
public void setCDate(int sysDate) {cDate = sysDate;}
public void setYr(String s) {yr = s;}
public void setMDates(Vector v) {m_dates.add(v);}
public int getCDate(){return crDate;}
public String getYr() {return yr;}
public Vector getMDates() {return m_dates;}
}
Now, in another class, I create objects of Dateclss, add them to a vector and store this vector in session.
I retrieve them back in a
JSP custom tag class. to retrive these values, I wrote the code like this
dates = session.getAttribute("dateObj");
Iterator i = dates.iterator();
while (i.hasNext())
{
dateIntFace dif = (dateIntFace)i.next();
int cd = dif.getCDate();
String syr = dif.getYr();
Vector v = dif.getMDates();
// I even tried Vector v = new Vector(); v = dif.getMDates();
}
when I do this, the int and string values are loading but its throwing error in retrieving getMDates(). I get runtime error. If I dont typecast it to Interface and typecast it to the class type, things are working fine but i get the warning of "object not serialized" for Dateclss object.
why is it not mapping a vector? why are things working fine when retrieving int and string values and why am i getting problem while retrieving a vector.
Can an interface have imports?
Can it throw variables of collection type?
Please let me know.
Thanks,
Padma.
[ December 01, 2003: Message edited by: N Padma ]