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] Re: [QF-Test] Problem with cast in Groovy script
Hi Clement, looks like it's the same class, but from a different ClassLoader. In Groovy - as in Jython - there's typically no need to cast, it's all based on reflection anyway. Simply remove the import for the Device class and the cast and you should be fine. Best regards, Greg MEVEL Clement <Clement.MEVEL@?.com> writes: > 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 -- Gregor Schmid Gregor.Schmid@?.de Quality First Software GmbH http://www.qfs.de Tulpenstr. 41 Tel: +49 8171 38648-0 DE-82538 Geretsried Fax: +49 8171 3864816 GF: Gregor Schmid, Karlheinz Kellerer HRB München 140833
|
1. Cookies fonctionnels
Nous utilisons des cookies fonctionnels pour garantir la fonctionnalité de base du site web.
2. Cookies de performance et de statistique
Nous utilisons Matomo pour analyser et améliorer notre site web. Des cookies permettent une collection anonyme des informations qui nous aident à vous offrir un visite clair et facile à utiliser de nos pages web.
This cookie contains a unique, pseudonymized visitor ID internal to Matomo for recognizing repeat visitors.
This cookie is used to track from which website the anonymized user proceeded to any page or sub-page.
The Matomo session cookie is used to track the visitor's page requests during the session. The cookie is automatically deleted at the end of each session (website visit), at the latest after one day.
is created and should be then directly deleted (used to check whether the visitor’s browser supports cookies).
short lived cookies used to temporarily store data for the visit.
short lived cookies used to temporarily store data for the visit.