Proposed content by rudi

[{TableOfContents }]

!!!Pagination of results ([<mak:list>|ListTag], [<mak:resultList>|ResultListTag])

When you retrieve more results from a [<mak:list>|ListTag] or [<mak:resultList>|ResultListTag] query than you would want to show to the user, you should utilise pagination. Pagination simply means you will display only a fixed number of ''n'' results on per page, and for the next results, the user has to click on a link/button to view the next ''n'' results. This technique is used e.g. in any web search engine.

Makumba provides integrated support for pagination both on regular data listing via the [<mak:list>|ListTag] tag, as well as on displaying results of a search, using [<mak:resultList>|ResultListTag]. This is achieved via the [<mak:pagination>|PaginationTag] tag, which will display the current page number, the total page number, and will provide links to the first, previous, next and last page with data. <mak:pagination> makes use of the information provided by the enclosing <mak:list> or <mak:resultList>, i.e. the %%code offset%% and %%code limit%%, and automatically computes the total of rows that would be returned by the list, if no limit was specified.

If we want to print the list of employees, and only view 15 employees per page, we could do this as follows:

[{Code

<mak:list from="company.Employee e" offset="$offset" limit="15">
  <mak:pagination action="employeeList.jsp" title="true" itemName="Employees" />
  <mak:value expr="e.nameSurname()"/>, born on <mak:value expr="e.birthdate" /> <br/>
  <mak:pagination action="employeeList.jsp" title="true" itemName="Employees" />
</mak:list>
}]

This will create a pagination header and footer, before and after the list of employees. The exact meaning of the attributes can be seen in the [<mak:pagination> reference documentation|PaginationTag].

The attributes %%code offset%% and %%code limit%% define the status of the pagination, i.e. from which result to display on (%%code offset%%), and how many results to display (%%code limit%%). In the example, we take use for the %%code offset%% attribute the parameter __$offset__, which is either a parameter to the page  (e.g. employeeList.jsp?offset=30), or defined elsewhere in the page, before the <mak:list>. If the parameter is __not__ present, then it will be assumed to be 0.

Navigation in the pagination is controlled by the attribute %%code action%%, which defines the target page to go to when clicking on a pagination link.

Finally, the appearance is controlled by a set of attrbiutes: %%code itemName%% is the the name of the items displayed, to be used in the text "Showing 'itemName' x out of y (Page z)", while %%code paginationLinkTitle%% decides whether or not to display title="..." elements on the pagination links.
Regarding layouting and formatting, the %%code styleClass%% sets the CSS class used for the pagination elements, and defaults to %%code makumbaPagination%%.

In the example above, the limit of items to be shown in the page was constant. However, often we want the user to chose how many items he wants to see at once. We can do this as follows:
[{Code

<mak:list from="company.Employee e" offset="$offset" limit="$limit" defaultLimit="15">
  <mak:pagination action="employeeList.jsp" title="true" itemName="Employees" />
  <mak:value expr="e.nameSurname()"/>, born on <mak:value expr="e.birthdate" /> <br/>
  <mak:pagination action="employeeList.jsp" title="true" itemName="Employees" />
</mak:list>
}]

In this case, we now also control the %%code limit%% by a changeable value. As before with the $offset, the value can be set via a page-parameter (e.g. employeeList.jsp?offset=50&limit=25), or be defined somewhere in the page before the <mak:list>.
If the value for $limit is __not__ defined, the <mak:list> will instead default to the value given by %%code defaultLimit%%.
!!!Different input controls for [<mak:input>|InputTag]

for sets: multi select list vs. checkbox
for enums: single select list vs. radio buttons
for integer: spinner, ..

!!!Form validation
Explain how to write [validation rules|ValidationRules]

%%(display:none;)[Category Usage]%%
