Display image in a table / Browse application - Kotlin

Hello All,
I am testing Jmix and I am brand new in the java / Kotlin world. I am having issue with this line exactly in the code below:
val image: Image = uiComponents.create(Image::class.java)

open class UserBrowse : StandardLookup() {
@Autowired
private lateinit var uiComponents: UiComponents

@Install(to = "usersTable.picture", subject = "columnGenerator")
private fun usersTablePictureColumnGenerator(user: User?): Component {
    val image: Image = uiComponents.create(Image::class.java).  **<--- Here**
    image.setScaleMode(Image.ScaleMode.CONTAIN)
    image.setSource(FileStorageResource::class.java)
        .setFileReference(user?.getPicture())
    image.setWidth("30px")
    image.setHeight("30px")

    return image

}

}

Please your help!

Thanks,
JA

Hi, Juan.

Try to use something like this:

    @Install(to = "usersTable.picture", subject = "columnGenerator")
    private fun usersTablePictureColumnGenerator(user: User?): Component {
        val image: Image<FileRef> = uiComponents.create(Image.NAME)

        image.scaleMode = Image.ScaleMode.CONTAIN

        user?.picture?.let {
            image.setSource(FileStorageResource::class.java)
                .setFileReference(it)
        }

        image.setWidth("30px")
        image.setHeight("30px")

        return image
    }

Seems to be working well.

Screenshot

image

Be sure to check out the documentation.
You can also see examples of using this component.

Regards,
Dmitriy

Thank you Dmitriy,
It just worked perfect!

Some questions:

  1. Is there any documentation for Jmix - Kotlin?
  2. Do you know if Jmix uses concurrency out of the box or we need to use Kotlin and code it if needed?
  3. Is it possible to use Jmix for desktop, PWA or mobile development?

I have an ERP made in PHP and plan to re-code it in a more robust and concurrent programming language.

Thank you,
JA

Concerning your questions:

  1. No. There is no documentation for Kotlin and is not planned.
  2. Could you elaborate more on what you mean by “concurrency out of the box”? Jmix and Kotlin provide the entire API for working with concurrency.
  3. Jmix with Classic UI (version before 2.0) is used only for creating classic web-applications, and is not mobile-friendly. The version of Framework with a FlowUI (version 2.0 and up) is great for writing convenient mobile-friendly web-applications.

Regards,
Dmitriy

Thank you for your quick response.

I am using version 2.0; do I have to do something to select FlowUI instead of Classic UI?

Thanks,
JA

In this case, if you are using version 2.0 of the framework, then you are already using FlowUI.
In version 2.0, the Classic UI has been removed.

I deduced that you are using the Classic UI from the code examples you provided.

Because classes and variables have been brought from the Classic.
As an example: StandardLookup, UserBrowse etc.

Regards,
Dmitriy