Remove annotation support for HX-Refresh, HX-Location and HX-Redirect
I would like to discuss whether we should drop the annotations @HxRefresh, @HxLocation and @HxRedirect, as it makes no sense to me to use them in a controller method in combination with a view as a return value. This would also simplify our code base and make things less confusing.
@wimdeblauwe what do you think?
Can you add an examples of how the code looks with the annotations and without? I will add a message on Twitter and Bluesky after that so people can give their opinion on this.
Spring MVC support special prefix like "redirect:/" Maybe return a string "hx:refresh"
I would like to discuss whether we should drop the annotations
@HxRefresh,@HxLocationand@HxRedirect, as it makes no sense to me to use them in a controller method in combination with a view as a return value. This would also simplify our code base and make things less confusing.
I don't use these as I don't see a use case as a controller annotation.
Can you add an examples of how the code looks with the annotations and without? I will add a message on Twitter and Bluesky after that so people can give their opinion on this.
@wimdeblauwe this is explained in the README.md#special-view-name-prefixes.
When using annotations, you can return a different view, such as template code, but the body of the response will be ignored by htmx. So instead of using the annotation you simple return one of the special view names or use one of the view classes as controller method return type.
| Annotation | View | View Name |
|---|---|---|
@HxRefresh |
HtmxRefreshView |
refresh:htmx |
@HxRedirect |
HtmxRedirectView |
redirect:htmx:/path |
@HxLocation |
HtmxLocationRedirectView |
redirect:htmx:location:/path |