https://kotlinlang.org logo
#kobweb
Title
# kobweb
a

abu naser

11/25/2023, 10:28 AM
Can i use data class in dynamic route ? // pages/users/user/posts/Post.kt @Page("/users/{user}/posts/{post}") // Or @Page("/users/{user}/posts/{}") @Composable fun PostPage() { /* ... */ } Here post and user will be data class . Or do i need to pass id then convert to data class manually ?
d

David Herman

11/25/2023, 10:57 PM
Technically, those values will just be string values, extracted from the URL typed in. So if you use something like kotlinx serialization, you could technically encode a class inside the URL. I'm not sure I'd recommend it.
I think it will look a lot cleaner if you keep {user} and {post} to simple values and then look up data using them.
❤️ 1
a

abu naser

11/27/2023, 4:00 PM
Thanks for your answer . One more question . I tried building simple kobweb project from scratch . I succeed at first project . But in my second attempt whenever i tried to appy kobweb.application plugin it throws Null pointer Exception ( no error message ) . It fixes after some gradle task i ran but i didn't find the reason for this error .
d

David Herman

11/27/2023, 6:51 PM
Unfortunately, I'm not sure how to help you there. I haven't seen an NPE myself and this is the first report I heard about this. If you find a way to repro this consistently, please let me know!
3 Views