-
I have been working with HTMX and have just found this library which seems to solve a few of the problems I am seeing as my application grows. However one thing I can't find any examples on is how to handle hx-request vs fresh page load events. The way I have done this so far is to just check whether that header is present in my controller and then act accordingly (returning a partial fragment if it is a hx-request, or the full-reload if it's not and that is possible e.g. for a deep-link). Is there a good way to handle this leveraging the spring-view-component library? Or perhaps just a better way in general? (I'm using svc + kotlin + kte with SpringBoot) Thanks in advance for your ideas. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Yeah that's probably the best idea. What I do is using a htmxutils class that checks if it's a hx request by getting the request from the http context statically. Then in your viewcomponent you can either return the ViewContext or delegate to the nested ViewComponent that is used for rendering. |
Beta Was this translation helpful? Give feedback.
-
Also @tschuehly I have a question about how you granular you use SVC. Do you go as far as making a generic 'FormViewComponent' , 'InputViewComponent' for example and compose using them across your app, or do you generally only go down to the 'UserFormComponent' as described in your workshop docs? Also, by the way, thanks for the resources you've provided around this library. It's good stuff, and I also found your recorded appearance at the conference to be very useful. |
Beta Was this translation helpful? Give feedback.
Yeah that's probably the best idea. What I do is using a htmxutils class that checks if it's a hx request by getting the request from the http context statically.
Then in your viewcomponent you can either return the ViewContext or delegate to the nested ViewComponent that is used for rendering.