Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Add HxTrigger #11

Closed
don41382 opened this issue Sep 14, 2023 · 9 comments
Closed

Proposal: Add HxTrigger #11

don41382 opened this issue Sep 14, 2023 · 9 comments

Comments

@don41382
Copy link

First and most important: Thank you for building the awesome plugin. I think the combination Spring + JTE +. htmx has huge potential!

I was wondering, what you would think about a @HxTrigger annotation, like htmx-spring-boot has included:
https://github.com/wimdeblauwe/htmx-spring-boot#response-headers

This is quite nice to have.

@tschuehly
Copy link
Owner

What do you want to do with HxTrigger? In my new project I am using htmx-spring-boot in combination with Spring ViewComponent and it pairs nicely.

@don41382
Copy link
Author

Ah, I didn't know that you can pair them. I will give this a try. That would make the need for HxTriggers obsolet. I wanted to trigger a refresh for certain parts, when it's not directly related to the triggering change. A user adds a todo to the list, the list refreshes (inside a different component)

Do you already know when 0.7. will be ready?

@tschuehly
Copy link
Owner

0.7 is mostly done but I will change the template context still a bit as I want to only pass in the record to the template and not just the properties.

But you can use 0.7-SNAPSHOT already as the tests are already passing. You can look at the example folder for a usage of the new record syntax.

@don41382
Copy link
Author

don41382 commented Sep 15, 2023 via email

@don41382
Copy link
Author

I just added the dependency (implementation("io.github.wimdeblauwe:htmx-spring-boot:3.0.0")) and get the following error:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'viewActionConfiguration' defined in URL [jar:file:/Users/felixeckhardt/.m2/repository/de/tschuehly/spring-view-component-core/0.7.0-SNAPSHOT/spring-view-component-core-0.7.0-SNAPSHOT.jar!/de/tschuehly/spring/viewcomponent/core/action/ViewActionConfiguration.class]: Unsatisfied dependency expressed through constructor parameter 1: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]: Factory method 'requestMappingHandlerMapping' threw exception with message: No qualifying bean of type 'org.springframework.web.servlet.ViewResolver' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier("viewResolver")}

Maybe you have an idea.

@tschuehly
Copy link
Owner

Can you post an example repo?
I could not reproduce the error locally in the kte example: https://github.com/tschuehly/spring-view-component/tree/v0.7.0-SNAPSHOT/examples/kte-example

@don41382
Copy link
Author

don41382 commented Sep 16, 2023

Here is my playground. It's a little e-mail address playground app. If you have any tips on how to improve it, please let me know:
https://github.com/don41382/htmxjetdemo

I compared your and my project. After removing @EnableWebMvc the exception on startup was gone. Thanks for the help.

I also added a few questions to the project:

@tschuehly
Copy link
Owner

I have to take a look at supporting @PathVariable with ViewActions.

I removed the EmptyContext as the template resolving is based the enclosing class of the data class/record

@tschuehly
Copy link
Owner

Hey there,

I removed the ViewActions from Spring ViewComponent in v0.8.0, as there is a better approach and the Annotation Processor added a lot of complexity.

The goal is to create a functional approach for HTMX Endpoints described here in an extension at a later date: wimdeblauwe/htmx-spring-boot#104

btw, you can add @ViewComponent and @Controller on the same class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants