Closed max-bertinetti closed 3 years ago
Thank you, good catch. Let me take a look at that but it should most probably be dataLoader = Article.dataLoader
@mvysny I finally make it work like this, but I don't know if it's the right way:
package com.example.vok
import com.github.mvysny.karibudsl.v10.*
import com.vaadin.flow.component.grid.Grid
import com.vaadin.flow.router.*
import com.github.vokorm.dataloader.dataLoader
import eu.vaadinonkotlin.vaadin10.vokdb.asDataProvider
@Route("articles")
class ArticlesView: KComposite(), AfterNavigationObserver {
private lateinit var grid: Grid<Article>
private val root = ui {
verticalLayout {
setSizeFull()
h1("Listing Articles")
grid = grid( dataProvider = Article.dataLoader.asDataProvider()) {
isExpand = true; setSizeFull()
addColumnFor(Article::id)
addColumnFor(Article::title)
addColumnFor(Article::text)
}
}
}
override fun afterNavigation(event: AfterNavigationEvent) {
grid.refresh()
}
}
package com.example.vok
import com.github.vokorm.*
import com.gitlab.mvysny.jdbiorm.Dao
import org.hibernate.validator.constraints.Length
import javax.validation.constraints.NotNull
data class Article(
override var id: Long? = null,
@field:NotNull
@field:Length(min = 5)
var title: String? = null,
@field:NotNull
@field:Length(min = 2)
var text: String? = null
) : KEntity<Long> {
companion object : Dao<Article, Long>(Article::class.java)
}
org.hibernate.validator is not imported I actually changed thevalidation with import
javax.validation.constraints.*
and
@field:Size(min = 5, max = 80)
Doing this the invalid form is also returned back without changing the button
import com.github.vokorm.getById
Unresolved reference: getById everywhere
Documentation contributions section is missing
I will love to contribute to this lovely project
Thank you so much :) you're right, the contribution docs is missing - I'll add it. But basically simply create a pr for files located at https://github.com/mvysny/vaadin-on-kotlin/tree/master/docs
The contributing guide is now present at https://www.vaadinonkotlin.eu/contributing.html :+1:
Ok. Can you please confirm that what I do in the above case for finish the tutorial is the right way?
Unresolved reference: getById everywhere
You're right - the function is no longer an extension function but is baked into the Dao class and thus doesn't need any import. I'll fix this.
What about my solution for org.hibernate.validator.constraints.Length and dataprovider? Are the right one?
@mvysny sorry to bother you, but I'm quite new to Kotlin and I don't do Java from 1.4
No problem! I think the tutorial doesn't probably mention that a dependency on Hibernate-validator needs to be added. I'll fix the docs in this regard as well.
Meanwhile, while the docs is fixed: please take a look at https://github.com/mvysny/vok-helloworld-app-v10 the "complete" branch. That's the full application sources which compile and work for me; while the docs are out-of-date, please find the correct code samples there.
Oh thank you! I don't see that branch lol!
I sended you an email.
There's a branch switcher combobox in GitHub which will take you to the branch; however here's a link to the "complete" sources: https://github.com/mvysny/vok-helloworld-app-v10/tree/complete
No, I know how Git and Github works, only I don't think about searching for it and is not mentioned in the tutorial.
Ah, you're right; added in 37f8cda2988c9ce4e030a6ca99e484fc71aba8df
@maxbertinetti you have done a wonderful job with the new documentation site. With your permission I'm closing this issue; please feel free to open new tickets if you discover something else not working (or simply create a PR for the docs :+1: )
Hi @mvysny.
I'm following the tutorial and when I arrive to section 5.8 Listing All Articles I get stuck:
vok-helloworld-app-v10/web/src/main/kotlin/com/example/vok/ArticlesView.kt: (6, 41): Unresolved reference: dataProvider