-
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 HxPush annotation #105
Comments
Can you give some examples of where you would use this? |
So it is an annotation alternative to using the
Not as convenient, and we require the URL in the |
I also like it. It will also need to support setting a custom url: @HxRequest
@HxPush //Implies the value of the current request mapping
@GetMapping(path=TasksWebPath.OVERVIEW_SCOPE)
public HtmxResponse taskOverview(@PathVariable("scope") String scope) {
ViewContext viewContext = taskOverview.renderTaskOverview(TaskScope.validate(scope));
return HtmxResponse.builder.addTemplate(viewContext).build();
} and @HxRequest
@HxPush("/alternate/path")
@GetMapping(path=TasksWebPath.OVERVIEW_SCOPE)
public HtmxResponse taskOverview(@PathVariable("scope") String scope) {
ViewContext viewContext = taskOverview.renderTaskOverview(TaskScope.validate(scope));
return HtmxResponse.builder.addTemplate(viewContext).build();
} |
Yeah most of my improvement ideas do not consider the HtmxResponse builder as I use ViewContexts instead. |
Just a reminder: I have already done the work for this and all other missing response header annotations in PR #67 (Commit for If you want to push the current request URL to the browser history just set @HxRequest
@GetMapping(path=TasksWebPath.OVERVIEW_SCOPE)
public HtmxResponse taskOverview(@PathVariable("scope") String scope) {
return HtmxResponse.builder()
.view(taskOverview.renderTaskOverview(TaskScope.validate(scope));)
.pushUrl("true") // or .pushUrl("/alternative/URL")
.build();
} BTW What I could imagine to simplify the use of the builder a bit would be a convenience method e.g. |
Right, thanks for reminding me about that @xhaggi. I don't have much time to work on this, but I would be happy to review a PR if somebody wants to take this up. |
@tschuehly could you please give us some more insight into your code? Why do you need a prefix and why do you add the I would recommend not moving too much htmx-specific code to the server side. If you want to push the current URL that htmx has requested to the browser history, simply add the attribute hx-push-url="true" to the HTML element in your template code. |
We needed a prefix when we had multiple I prefer doing it on the Endpoints as I don't know at component creation time if I need to push the URL or not. |
@wimdeblauwe @xhaggi |
#118 has been merged now and |
We have a working HxPush annotation using an Interceptor, should I create a PR?
The text was updated successfully, but these errors were encountered: