07-29-2009 07:30 AM
I have added two objectchoiceFields in a HFmanager and when i try to do these , give me class cast exceptions
Also i tried this
Solved! Go to Solution.
07-29-2009 07:38 AM
07-29-2009 07:41 AM
I am assuming that "row6" is the instance of your HorizontalFieldManager.
If yes -
getOriginal() is not going to work at all, it is a method of Field class, so that is out of question.
The second option is right , which says "ObjectChoiceField field6=(ObjectChoiceField)row6.getField(0);" and here it must be giving classclastexception is because, the field at 0th location is not the ObjectChoiceField. Try the getFieldCount() method which will tell you that if there are fields in the manager, try with a different index say "1".
07-29-2009 07:48 AM
i did this
Object getChoice(int index)
but it gives me nullpointerexception
07-29-2009 07:53 AM
07-29-2009 07:59 AM
give me a favour.
can you tell me, how can i apply getselectedindex()
bcoz i need to get the field first from my HFManager.
how can i do that bcoz i am getting class exception for that.
07-29-2009 08:16 AM
Brother, class castexception is thrown when you try to convert in opposite direction in class hierarchy.
this gives me this cast exception.
My problem is , how can you get the ObjectChoiceField out from the HFManager if not then how can i get the selected choice from it.
07-29-2009 08:26 AM
Brother, i know why classcasexception is thrown -
First of all we need to see if the getField(index) method is returning you valid ObjectChoiceFIeld or not, and if it is not, type casting it to (ObjectChoiceField) will definitely give you classcastexception.
Object obj = row6.getField(1 or 0 or watever integer);
if(obj instanceof ObjectChoiceField)
field6 = (ObjectChoiceField)obj;
I am assuming - row6 = HorizontalFieldManager and field6 = ObjectChoiceField,
07-29-2009 10:03 AM