@RequestMapping(value = "/user/roleList.do", method = RequestMethod.GET)
public ModelAndView roleList(HttpServletRequest request, HttpSession session) throws Exception {
log.debug("RoleListAction");
long s = System.currentTimeMillis();
ZeroView view = new ZeroView(getMessages(), request.getLocale());
User user = getUser();
logFunction("user-rolelist");
if (user.checkAuthorisation(UserModule.AUTH_USER)) {
view.addWidget(new SimpleWidget(ZeroView.DIV_CONTENT, "user_rolelist"));
FormWidget filter = (FormWidget) getWidgetManager(session).getWidget("ROLELIST_FILTER");
if (filter == null) {
filter = new FormWidget("ROLELIST_FILTER", getLocale(request));
filter.setColumnCount(2);
filter.setShowLabelAtTop(true);
filter.addField(new StringField("name", "base.user.table.name", ""));
ComboBoxField groupField = new ComboBoxField("userGroup", "base.user.label.usergroupkey", "");
groupField.addOption("", "*");
for (UserGroup userGroup : getUserGroups()) {
groupField.addOption(userGroup.getId(), userGroup.getGroupKey());
}
filter.addField(groupField);
filter.setForm("RoleFilterForm");
getWidgetManager(session).register(filter);
}
view.addWidget(filter);
HtmlTableWidget roleWidget = (HtmlTableWidget) getWidgetManager(session).getWidget("ROLELIST");
if (roleWidget == null) {
DefaultTableModelColumn nameColumn = new DefaultTableModelColumn("base.user.table.rolename", "name");
nameColumn.setStyleClass("emphasize");
/* usernameColumn.addClickListener(new TableClickListener() {
public void fireClicked(TableClickEvent event) {
log.debug("fireClicked: " + event.getWidget().getModel().getData(event.getColumn(), event.getRow()));
}
});*/
RoleTableModel model = new RoleTableModel(getRoles(user), getMessages(), request.getLocale());
if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {
model.setSelectable(true);
DefaultTableModelColumn editColumn = new DefaultTableModelColumn("", "");
editColumn.setRenderer(new TableColumnRenderer() {
public String getTemplate() {
return "v2js_widgets_tablelink";
}
public Object getData(Object obj) {
if (obj instanceof Role) {
JSONObject jLink = new JSONObject();
jLink.element("url", "user/roleEdit.do?selected=" + ((Role) obj).getId());
jLink.element("text", "Edit");
return jLink;
}
return "";
}
});
model.addColumn(editColumn);
}
model.addColumn(nameColumn);
model.addColumn(new DefaultTableModelColumn("base.user.label.usergroupkey", "userGroup.groupKey"));
model.setSort(1);
roleWidget = new HtmlTableWidget("ROLELIST", model);
roleWidget.setRowsPerPage(20);
getWidgetManager(session).register(roleWidget);
} else {
((RoleTableModel) roleWidget.getModel()).setCollection(getRoles(user));
}
view.addWidget(roleWidget);
if (user.checkAuthorisation(UserModule.AUTH_ROLE_EDIT)) {
view.getJson().element("edit", true);
}
}
log.debug("role list: " + (System.currentTimeMillis() - s));
return new ModelAndView(view, null);
}