-
Notifications
You must be signed in to change notification settings - Fork 49
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
Add support HtmxResponse that isn't a direct return type #127
Comments
Reporting back: Option 3 won't work. Spring selects only one handler. That also means that option 1 won't work. Perhaps option 2 will work. |
@wimdeblauwe How do you feel about PR #128 ? It is working really well for me in my 3 projects that I've migrated to JTE |
Hi @checketts, sorry I forgot about this. If you can just add some documentation, we can merge it and I will create a new release for you. |
I just pulled this into a project and it is working great! |
@checketts Do you have a special implementation in your projects to handle |
@xhaggi Yes. I'll try to upload a sample project (and hopefully push upstream into the JTE Spring module) |
Returning a JTE Model with Spring is not present in the main project, yet the concept aligns with the expected usecase. This isn't too surprising since the primary JTE committer doesn't use Spring. I'm new to these internals, so I'm not familiar with how #137 might be impacted with the My primary usecase is having a programatic way to set HTMX headers following the same pattern you might use with However as long as injecting the |
I agree with that. This gives me the idea that maybe we should remove the support for adding views from Something like Single view String user(HtmxResponse res) {
res.trigger("mytrigger");
return "myview";
} Multiple views HtmxView user(HtmxResponse res) {
res.trigger("mytrigger");
var view = new HtmxView();
view.add("myfragment1");
view.add("myfragment2");
return view;
} This would bring the implementation more in line with Spring. @wimdeblauwe what do you think? |
Spring Framework 6.2 (Which is due November 2024) will support multiple fragments: https://docs.spring.io/spring-framework/reference/6.2/web/webmvc-view/mvc-fragments.html#page-title Maybe we should take that in account? I would be ok with releasing a 4.0 that needs 6.2 (When it is released and a compatible Spring Boot version is available obviously). |
Good to know. This will make things much easier in the future. How about introducing |
Would we have So if I understand it correctly, we want to make We do have to make sure it can still work as a global error handler as documented in https://github.com/wimdeblauwe/htmx-spring-boot?tab=readme-ov-file#error-handlers |
I favor |
@wimdeblauwe You are right. I'm already working on it and it's almost finished.
I need to check if this is possible. At the moment I am using |
I think it is ok to use |
I've working with JTE as my templating engine recently and been very impressed. The templates are statically compiled and work very well with this library.
However there is an advanced use case where the Gradle or maven plugin generates an
interface
that represents your templates, complete with parameters.To leverage these templates I'm returning a
JteModel
in my controller methods, that isn't compatible with this library. I would like to propose a few solutions.1- Support subclassing
HtmxResponse
. I might be able to leverage that so myJteModel
provides the right data.2- Support making
HtmxResponse
an injectable parameter, similar to how you can set the response code when injectingHttpServletResponse
.3- Support a 'provider' approach for
HtmxResponse
. This means my response can implement an interface and provide anHtmxResponse
, allowing the builder to remain the same but making the return type more flexible.I'll start on a PR for option 3. But I'm interested in feedback on any and all of these options.
The text was updated successfully, but these errors were encountered: