Skip to content
This repository was archived by the owner on Mar 14, 2021. It is now read-only.
This repository was archived by the owner on Mar 14, 2021. It is now read-only.

Keybindings on case class with option val #30

@ASchmidt84

Description

@ASchmidt84

Hi,

I have a little problem and I missing an example for that.

I have a case class like this:

case class PatientView(number: String,
                       personalData: PersonalData,
                       postalAddress: Option[PostalAddress])

case class PostalAddress(addressLine1: String,
                         addressLine2: Option[String],
                         streetLine: String,
                         postalCode: String,
                         city: String,
                         state: Option[String],
                         countryLine: Option[Country])

And a Textfield and a binding like this:

patientAdapter.addBinding(streetField.text,"${_self.postalAddress().addressLine1()}")

this will lead in an exception! Of course it is None. When I add a StringConverter like this

val conv = StringConverter.toStringConverter[PatientView](r => "OKAY")
    patientAdapter.addBinding(streetField.text,"${_self.postalAddress()}",Some(conv))

will lead in an exception like this

class java.lang.String cannot be cast to class de.hp.patient.api.adt.PatientView (java.lang.String is in module java.base of loader 'bootstrap'; de.hp.patient.api.adt.PatientView is in unnamed module of loader 'app')

How I can access an none and also set an Some on change?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions