Skip to content

Commit 4b3bfb8

Browse files
author
jpenren
committed
Merge remote-tracking branch 'origin/master'
2 parents 23b54ac + ce508b2 commit 4b3bfb8

File tree

1 file changed

+127
-22
lines changed

1 file changed

+127
-22
lines changed

README.md

Lines changed: 127 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Data pagination made easy with thymeleaf and spring data.
33

44
This is a dialect for Thymeleaf that provides some attributes to create pagination and sorting elements, bootstrap style, based on Spring Data.
55

6+
Thymeleaf 2 version here (https://github.com/jpenren/thymeleaf-spring-data-dialect/tree/thymeleaf-2)
7+
68
Usage
79
-----
810

@@ -29,41 +31,144 @@ public String list(ModelMap model, @SortDefault("username") Pageable pageable){
2931
}
3032
```
3133

32-
Your html page looks like
34+
Your html page looks like:
3335
```html
3436
<table class="table table-striped table-hover">
3537
<thead>
36-
<tr>
37-
<th><a class="sorted" sd:pagination-sort="username" >Username</a></th>
38-
<th><a class="sorted" sd:pagination-sort="firstName" >First name</a></th>
39-
<th>Last Name</th>
40-
<th></th>
41-
</tr>
38+
<tr>
39+
<th><a class="sorted" sd:pagination-sort="username" >Username</a></th>
40+
<th><a class="sorted" sd:pagination-sort="firstName" >First name</a></th>
41+
<th>Last Name</th>
42+
<th></th>
43+
</tr>
4244
</thead>
4345
<tbody>
44-
<tr th:each="row : ${page}">
45-
<th scope="row" th:text="${row.username}">Username</th>
46-
<td th:text="${row.firstName}">Name</td>
47-
<td th:text="${row.lastName}">Last Name</td>
48-
<td><a href="#">edit</a></td>
49-
</tr>
46+
<tr th:each="row : ${page}">
47+
<th scope="row" th:text="${row.username}">Username</th>
48+
<td th:text="${row.firstName}">Name</td>
49+
<td th:text="${row.lastName}">Last Name</td>
50+
<td><a href="#">edit</a></td>
51+
</tr>
5052
</tbody>
5153
</table>
5254

5355
<div class="row">
5456
<div class="col-sm-6">
55-
<div sd:pagination-summary="pagination.summary">info</div>
57+
<div sd:pagination-summary>info</div>
5658
</div>
5759
<div class="col-sm-6">
5860
<nav class="pull-right">
59-
<ul class="pagination" sd:pagination="full">
60-
<!-- Pagination created by SpringDataDialect, this content is just for mockup -->
61-
<li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
62-
<li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
63-
</ul>
64-
</nav>
61+
<ul class="pagination" sd:pagination="full">
62+
<!-- Pagination created by SpringDataDialect, this content is just for mockup -->
63+
<li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
64+
<li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
65+
</ul>
66+
</nav>
6567
</div>
6668
</div>
67-
```
69+
```
70+
71+
![alt text](https://raw.githubusercontent.com/jpenren/thymeleaf-spring-data-dialect/master/doc/simple.png "Simple")
72+
73+
Pagination with pager:
74+
```html
75+
<nav>
76+
<ul class="pagination" sd:pagination="pager">
77+
<!-- Pagination created by SpringDataDialect, this content is just for mockup -->
78+
<li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
79+
<li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
80+
</ul>
81+
</nav>
82+
```
83+
84+
![alt text](https://raw.githubusercontent.com/jpenren/thymeleaf-spring-data-dialect/master/doc/pager.png "Pager")
85+
86+
Aligned links:
87+
```html
88+
<nav>
89+
<ul class="pagination" sd:pagination="aligned-links">
90+
<!-- Pagination created by SpringDataDialect, this content is just for mockup -->
91+
<li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
92+
<li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
93+
</ul>
94+
</nav>
95+
```
96+
97+
![alt text](https://raw.githubusercontent.com/jpenren/thymeleaf-spring-data-dialect/master/doc/aligned-links.png "Aligned links")
98+
99+
Multiple tables on the same page:
100+
101+
On @Controller
102+
```java
103+
@RequestMapping("/users")
104+
public String list(ModelMap model, @Qualifier("foo") Pageable first, @Qualifier("bar") Pageable second){
105+
model.addAttribute("page", userService.find(first));
106+
model.addAttribute("page", userService.find(second));
107+
108+
return "users/list";
109+
}
110+
```
111+
```html
112+
<div class="row">
113+
<div class="col-md-6" sd:page-object="${page}" sd:pagination-qualifier="foo">
114+
<div class="panel panel-default">
115+
<div class="panel-body">
116+
<table class="table table-striped table-hover">
117+
<thead>
118+
<tr>
119+
<th><a class="sorted" sd:pagination-sort="username" >Username</a></th>
120+
<th><a class="sorted" sd:pagination-sort="firstName" >First name</a></th>
121+
</tr>
122+
</thead>
123+
<tbody>
124+
<tr th:each="row : ${page}">
125+
<td th:text="${row.username}">First Name</td>
126+
<td th:text="${row.firstName}">Last Name</td>
127+
</tr>
128+
</tbody>
129+
</table>
130+
131+
<nav>
132+
<ul class="pagination" sd:pagination="full">
133+
<!-- Pagination created by SpringDataDialect, this content is just for mockup -->
134+
<li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
135+
<li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
136+
</ul>
137+
</nav>
138+
</div>
139+
</div>
140+
</div>
141+
<div class="col-md-6" sd:page-object="${barPage}" sd:pagination-qualifier="bar">
142+
<div class="panel panel-default">
143+
<div class="panel-body">
144+
<table class="table table-striped table-hover">
145+
<thead>
146+
<tr>
147+
<th><a class="sorted" sd:pagination-sort="username" >Username</a></th>
148+
<th><a class="sorted" sd:pagination-sort="firstName" >First name</a></th>
149+
</tr>
150+
</thead>
151+
<tbody>
152+
<tr th:each="row : ${barPage}">
153+
<td th:text="${row.username}">First Name</td>
154+
<td th:text="${row.firstName}">Last Name</td>
155+
</tr>
156+
</tbody>
157+
</table>
158+
159+
<nav class="">
160+
<ul class="pagination" sd:pagination="full">
161+
<!-- Pagination created by SpringDataDialect, this content is just for mockup -->
162+
<li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
163+
<li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
164+
</ul>
165+
</nav>
166+
</div>
167+
</div>
168+
</div>
169+
</div>
170+
```
171+
172+
![alt text](https://raw.githubusercontent.com/jpenren/thymeleaf-spring-data-dialect/master/doc/multiple-tables.png "Multiple tables")
68173

69-
It's all, by default SpringDataDialect search in the request for the attribute "page" or if one attribute of type org.springframework.data.domain.Page<?> exists.
174+
By default SpringDataDialect search in the request for the attribute "page" or if one attribute of type org.springframework.data.domain.Page<?> exists. To use another model attribute, use sd:page-object="${attrName}"

0 commit comments

Comments
 (0)