List Icon
Archive de la liste de diffusion

La liste de diffusion est fermée depuis juillet 2022, mais sert toujours d'archive d'informations sur QF-Test.
Cependant, si vous souhaitez rester informé des nouveautés concernant QF-Test, vous pouvez simplement vous abonner à la newsletter :
abonner à la newsletter 


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[QF-Test] Problem with cast in Groovy script


  • Subject: [QF-Test] Problem with cast in Groovy script
  • From: MEVEL Clement <Clement.MEVEL@?.com>
  • Date: Thu, 3 Jan 2013 14:38:52 +0000

Hi all,

 

In a JList of a GUI there are complex objects and there is a renderer set to display a readable name.

I am trying in a Groovy script to retrieve the elements of a combo box to get their data for using them.

Here is a part of the script:

 

import javax.swing.JComboBox

import javax.swing.JList

import sercel.spn.surveycontrol.gui.model.observations.Device

 

(…)

list = rc.getComponent("GenericList")

nbListItems = list.getModel().getSize()

 

for (i in 0..<nbListItems){

    currentListItem = (Device) list.getModel().getElementAt(i)

    rc.println("Name : "+currentListItem.getName())

    rc.println("Id : "+currentListItem.getId())

}

 

 

And here are the error result of execution:

Cannot cast object

'sercel.spn.surveycontrol.gui.model.observations.Device@9f14c3'

with class

'sercel.spn.surveycontrol.gui.model.observations.Device'

to class

'sercel.spn.surveycontrol.gui.model.observations.Device'

 

Any idea?

 

Best regards

 

Clement Mevel