List Icon
Mailing list Archive

2019 up to July 2022 | 20182017  |  2016  2015 2014 | 2013

The mailing list has been closed since July 2022, but continues to serve as an archive of information about QF-Test.
But if you want to stay informed about news about QF-Test, you can simply
Subscribe to Newsletter  

To get up-to-date information about each release - including minor releases - you can
subscribe to the RSS feed or follow us on social media.
Alternatively, QF-Test also provides release information itself.

Another source of information is our blog, where there are current articles on general topics, on the company QFS and also various "how-tos"
subscribe to blog


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

Re: [QF-Test] Problem with cast in Groovy script


  • Subject: Re: [QF-Test] Problem with cast in Groovy script
  • From: Gregor Schmid <Gregor.Schmid@?.de>
  • Date: Thu, 03 Jan 2013 17:17:35 +0100

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