String role = request.getParameter("role");
String maxRows = request.getParameter("maxRows");
int rows = Integer.parseInt(maxRows == null ? "10" : maxRows);
String filter = (role == null ? "" : Util.urlDecode(role)) + "*";
Role[] roles = userDatabase.listAllRoles(filter, rows);
List<Role> sortedRoles = new ArrayList<Role>(Arrays.asList(roles));
Collections.sort(sortedRoles);
for (Role foundRole : sortedRoles) {
String encodedHtml = Util.encodeHTML(foundRole.getPrincipalName());
builder.addItem(encodedHtml, encodedHtml);