Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error while setting the session for Enumeration

 
Raj kalaria
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to set a session in one of my class and trying to call in another class

------------------------------code----------------------------
try {
s_Query = ((DfQueryBuilder) m_IDfQueryBuilder).getDocbaseQuery("YOUR_DOCBASE_NAME");
} catch (DfException e) {
e.printStackTrace();
}
getPageContext().getSession().setAttribute("newTest",s_Query);
--------------------------code ----------------------------------

the above piece of code works fine i am able to get teh session s_Query in the 2nd class

myquery =SessionState.getAttribute("newTest").toString();

----------------------------------------------------------------------

But the prblem is when i set a Enumeration variable in the session it gives me an error "Object in session is not serializable"


------------------- my code ---------------------------
IDfEnumeration enumDispAttr = getSearchInfo().getSmartListDefinition().getDisplayAttributes();

getPageContext().getSession().setAttribute("col",enumDispAttr);

--------------------------------------------------------------------------

now in my other class i access as follow

IDfEnumeration enumDispAttr3 = (IDfEnumeration)SessionState.getAttribute("col");
System.out.println("this is before1 session" );
try {

while(enumDispAttr3.hasMoreElements())
{

String strAttr3 = (String) enumDispAttr3.nextElement();
System.out.println("The value of enumstring in the excell class is :"+ strAttr3);

}
}
catch (Exception e)
{
System.out.println("the mistake here is" + e );
}


can you guys tell me how to pass Enumeration in session variables
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An Enumeration is a 'cursor' type, and if they are now serializable then they're not serializable. You can either pass the parent object (if available) or iterate through the Enumeration, move each element to another data type, and then store that instead.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic