How to make working this `val curSelectedItem = Si...
# announcements
c
How to make working this
val curSelectedItem = SimpleObjectProperty<ItemViewInstance>()
with something like this
when (curSelectedItem) { is ItemViewInstance.ItemModel }
? it works only if
curSelectedItem
isnt
SimpleObjectProperty
d
Is
ItemViewInstance.ItemModel
a subclass of
SimpleObjectProperty
?
c
No, I use it to identify what view is used as current opened, ItemModel is data class inside of sealed class
d
In that case
is
won't be possible then. It's only for subclasses.
What is your intention with the
when
?
OH! You want to check if the generic parameter of
SimpleObjectProperty
is a subclass of
ItemViewInstance.ItemModel
?
c
see, I have
sealed class
with different `data class`es inside, so I wanna check if the
Item
I’m working with belongs to specific
data class
. Hope you understand, if dont - I can put some snippets on top of my words
d
Is there an public property inside of
SimpleObjectProperty
that is of type
ItemViewInstance
?
c
I don’t get what means ‘property inside of property’, I haven’t used it this way as I think, so the answer is no
d
Can I see what SimpleObjectProperty looks like?
c
Adding
.value
to
curSelectedItem
fixed a problem
s
I have a feeling that you have misunderstood how to use JavaFX properties. Usually you want to bind to them, or add listeners. If you're not careful, you will run into inconsistencies when the contents of the SimpleProperty change
c
@SiebelsTim I’m binding an object to the property but in case above I need to work with property object’s id, but its not accessible if I’m not checking the type of the property im working with.
s
That's all right. But if you don't do it inside a ChangeListener, you might risk inconsistencies
c
Hm, actually I have list of item groups on left pane and items of these groups on right pane. Regard on which group is currently selected, I’m receiving objects from server to fulfil list with data of this group, and as selected property is changed to another I set list on right pane with data of its group. Is there any other construction I could deal with?
s
That seems correct. I might have jumped to conclusions that I shouldn't have. You said you are doing it when the selected property changes, and that sound correct :)
c
Anyway thanks for attention, as for beginner thats useful to think about such a things 🙂