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

Remove unnecessary servlet response manipulations #5

Merged
merged 4 commits into from
Oct 22, 2023

Conversation

dsyer
Copy link
Member

@dsyer dsyer commented Sep 22, 2023

No description provided.

@agrison
Copy link
Collaborator

agrison commented Sep 25, 2023

I don't see why this is a very big problem (related to uglyness) for the BE to drive the URL for these pagination steps.

With the changes you propose, the URL are no more bookmarkable when changing page, the URL doesn't get updated anymore and stays on /owners/find instead of say /owners/find?lastName=Davis&page=1.

We would need to fix that, also I think on vets.html but this was a missing feature probably, it should have worked the same way it worked on searching owners.

@dsyer
Copy link
Member Author

dsyer commented Sep 26, 2023

You don't think servlet API references in controllers is ugly? I suppose it's not for me to say.

Anyway, I see what you mean about the URL query params being bookmarkable - I don't recall ever seeing them, but I was probably not looking hard enough. The vets link has no query params so I might hack the PR around until it is the smallest it can be without changing bookmarks.

@dsyer
Copy link
Member Author

dsyer commented Oct 2, 2023

I updated the OwnerController to preserve the form query params in the hx-push-url using HtmxResponse from the HTMX library. The other endpoints all seem fine without changing the controllers, or maybe I missed something.

@dsyer dsyer force-pushed the push-url branch 2 times, most recently from fce19de to 9a4ee11 Compare October 6, 2023 05:54
@@ -122,9 +122,13 @@ <h2>Pets and Visits</h2>
</tr>
<tr>
<td><a th:href="@{__${owner.id}__/pets/__${pet.id}__/edit}"
th:attr="hx-get=@{__${owner.id}__/pets/__${pet.id}__/edit}" hx-target="#block-content">Edit Pet</a></td>
hx:get="@{__${owner.id}__/pets/__${pet.id}__/edit}"
hx:push-url="@{__${owner.id}__/pets/__${pet.id}__/edit}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could replace this with hx-push-url="true" and it should work just the same.

Copy link
Member Author

@dsyer dsyer Oct 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I also replaced all the unnecessary HttpServletRequest and HttpServletResponse method parameters. I wonder if we even need the HtmxResponse (controller methods can return strings if there is only one view to render), but I didn't go that far.

@agrison agrison merged commit e51d734 into spring-petclinic:main Oct 22, 2023
1 check passed
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

Successfully merging this pull request may close these issues.

3 participants