-
Notifications
You must be signed in to change notification settings - Fork 661
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
Adjust Paging's sort in order to make it easy to build link based on it #2952
Comments
Using I'm not fully sure we have an utility to render |
Mark is right. That said, given the popularity of Thymeleaf, I wonder if it makes sense to investigate options how we can make such link creation easier. If in doubt, I would start with a dedicated model object in application code that would use the Spring MVC / HATEOAS APIs. Those allow creating full links by pointing at controller methods to use the rendered URIs in the template instead of constructing the URI in the template in the first place. |
I've have a different opinion on this. But that's not the point to me. My point is that, getting informations (page size and current page) from pageable is easy. Maybe from sort, a method to get easy access sort and sort order would help. Maybe somthing along thoses lines:
First would give the first sort or unsorted. |
There's been a Spring Data-specific Thymeleaf dialect once. It looks pretty dated, but I wonder if we could / should provide something like this ourselves. EDIT: It looks like I oversaw the latest releases. I'd just recommend to use that then. Btw. I am not arguing that an application-level model should be the ultimate solution. All I am saying is that there is already an API in place to create links to controller methods in a type-safe way. I'd recommend using those over concatenating arbitrary strings in HTML snippets any time, until we find a better solution. That said, changing
Finally, I don't buy the “this should be in the template” argument as the template is not what governs the URI structure, the controller method is. That's why it makes sense to keep the creation of links pointing to those close to them, and also type safe as you would want to realize your link creation breaks in case you change the signature of the controller method. |
I'm trying to write link like this
/resources?page=11&size=100&sort=name,asc.
And my thymleaf templates looks like this
My issue is that this template, will produce the following link
But this is not handeled correctly by spring mvc. I could not found a way to easely build the given link with the current API.
So I ended up writing this
Maybe the best solution is not in spring-data-core but in spring mvc. Or maybe there is a solution that I wasnt able to find.
The text was updated successfully, but these errors were encountered: