- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试为我的 portlet 创建一个搜索表单。portlet 是一个地址簿应用程序,所有 dao 和服务都是通过服务构建器构建的。我想为用户提供一个基本/高级搜索表单(就像 liferay 上的其他搜索表单一样,例如控制中心的“用户和组织”。
我已经实现了查看liferay源代码(6.1 GA1)的所有逻辑和页面,但是搜索表单没有以任何方式显示,我将把代码放在这里。
在view.jsp中:
<%
PortletURL portletURL = renderResponse.createRenderURL();
portletURL.setParameter("jspPage", "/html/addressbookportlet/view.jsp");
pageContext.setAttribute("portletURL", portletURL);
String portletURLString = portletURL.toString();
%>
<aui:form action="<%= portletURLString %>" method="get" name="fm">
<liferay-portlet:renderURLParams varImpl="portletURL" />
<aui:input name="isSearch" type="hidden" value="true" />
<aui:input name="redirect" type="hidden" value="<%= portletURLString %>" />
<liferay-ui:search-container
searchContainer="<%= new ABContactSearch(renderRequest, portletURL) %>"
>
<%
ABContactDisplayTerms displayTerms = (ABContactDisplayTerms)searchContainer.getDisplayTerms();
ABContactSearchTerms searchTerms = (ABContactSearchTerms)searchContainer.getSearchTerms();
Long societyId = GetterUtil.getLong(searchTerms.getSocietyId(),0);
Long contactTypeId = GetterUtil.getLong(searchTerms.getContactTypeId(), 0);
Long brandId = GetterUtil.getLong(searchTerms.getBrandId(),0);
Long channelId = GetterUtil.getLong(searchTerms.getChannelId(),0);
%>
<liferay-ui:search-form
searchContainer="<%=searchContainer%>"
servletContext="<%= this.getServletConfig().getServletContext() %>"
showAddButton="true"
page='<%= request.getContextPath() + "/html/addressbookportlet/contact_search_form.jsp" %>'
/>
<liferay-ui:search-container-results>
<%
if (searchTerms.isAdvancedSearch()) {
results = AddressbookSearchUtil.searchAdvanced(scopes, searchTerms, searchTerms.isAndOperator(), searchContainer.getStart(), searchContainer.getEnd()); //, searchContainer.getOrderByComparator());
total = AddressbookSearchUtil.countAdvanced(scopes, searchTerms, searchTerms.isAndOperator());
}
else {
results = AddressbookSearchUtil.searchFullText(scopes, searchTerms.getKeywords(), searchContainer.getStart(), searchContainer.getEnd()); //, searchContainer.getOrderByComparator());
total = AddressbookSearchUtil.countFullText(scopes, searchTerms.getKeywords());
}
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
%>
</liferay-ui:search-container-results>
<liferay-ui:search-container-row
className="it.mir4unicomm.addressbook.model.ABContact"
escapedModel="<%= true %>"
keyProperty="contactId"
modelVar="abcontact"
>
<liferay-ui:search-container-column-text
title="Surname"
property="surname"
/>
<liferay-ui:search-container-column-text
title="Name"
property="name"
/>
<liferay-ui:search-container-column-text
title="Position"
property="position"
/>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
</aui:form>
contact_search_form.jsp:
<%@ include file="/html/addressbookportlet/init.jsp" %>
<%
the
ABContactDisplayTerms displayTerms = (ABContactDisplayTerms)searchContainer.getDisplayTerms();
List<ABSociety> societyList = ABSocietyLocalServiceUtil.getABSocieties(0, Integer.MAX_VALUE);
List<ABBrand> brandList = ABBrandLocalServiceUtil.getABBrands(0, Integer.MAX_VALUE);
List<ABContactType> contactTypeList = ABContactTypeLocalServiceUtil.getABContactTypes(0, Integer.MAX_VALUE);
List<ABChannel> channelList = ABChannelLocalServiceUtil.getABChannels(0, Integer.MAX_VALUE);
%>
<liferay-ui:search-toggle
id="toggle_id_contact_search"
displayTerms="<%= displayTerms %>"
buttonLabel="search-contact"
>
<aui:fieldset>
<aui:input name="<%= ABContactDisplayTerms.SURNAME %>" size="20" value="<%= displayTerms.getSurname() %>" />
<aui:input name="<%= ABContactDisplayTerms.NAME %>" size="20" value="<%= displayTerms.getName() %>" />
<aui:input name="<%= ABContactDisplayTerms.POSITION %>" size="20" value="<%= displayTerms.getPosition() %>" />
<aui:input name="<%= ABContactDisplayTerms.DETAIL_VALUE %>" size="20" value="<%= displayTerms.getDetailValue() %>" />
</aui:fieldset>
</liferay-ui:search-toggle>
<c:if test="<%= windowState.equals(WindowState.MAXIMIZED) %>">
<aui:script>
Liferay.Util.focusFormField(document.<portlet:namespace />fm.<portlet:namespace /><%= ABContactDisplayTerms.SURNAME %>);
Liferay.Util.focusFormField(document.<portlet:namespace />fm.<portlet:namespace /><%= ABContactDisplayTerms.KEYWORDS %>);
</aui:script>
</c:if>meDisplay.setIncludeServiceJs(true);
ABContactSearch searchContainer = (ABContactSearch)request.getAttribute("liferay-ui:search:searchContainer");
ABContactDisplayTerm.java:
public class ABContactDisplayTerms extends DisplayTerms {
public static final String NAME = "name";
public static final String SURNAME = "surname";
public static final String POSITION = "position";
public static final String SOCIETY_ID = "societyId";
public static final String CONTACT_TYPE_ID = "contactTypeId";
public static final String BRAND_ID = "brandId";
public static final String CHANNEL_ID = "channelId";
public static final String DETAIL_VALUE = "detailValue";
protected String name;
protected String surname;
protected String position;
protected Long societyId;
protected Long contactTypeId;
protected Long brandId;
protected Long channelId;
protected String detailValue;
public ABContactDisplayTerms(PortletRequest portletRequest) {
super(portletRequest);
name = ParamUtil.getString(portletRequest, NAME);
surname = ParamUtil.getString(portletRequest, SURNAME);
position = ParamUtil.getString(portletRequest, POSITION);
societyId = ParamUtil.getLong(portletRequest, SOCIETY_ID);
contactTypeId = ParamUtil.getLong(portletRequest, CONTACT_TYPE_ID);
brandId = ParamUtil.getLong(portletRequest, BRAND_ID);
channelId = ParamUtil.getLong(portletRequest, CHANNEL_ID);
detailValue = ParamUtil.getString(portletRequest, DETAIL_VALUE);
}
public String getName() {
return name;
}
public String getSurname() {
return surname;
}
public String getPosition() {
return position;
}
public Long getSocietyId() {
return societyId;
}
public Long getContactTypeId() {
return contactTypeId;
}
public Long getBrandId() {
return brandId;
}
public Long getChannelId() {
return channelId;
}
public String getDetailValue() {
return detailValue;
}
}
最后是 ABContactSearch.java
public class ABContactSearch extends SearchContainer<ABContact> {
private static Log _log = LogFactoryUtil.getLog(ABContactSearch.class);
static List<String> headerNames = new ArrayList<String>();
static Map<String, String> orderableHeaders = new HashMap<String, String>();
static {
headerNames.add("name");
headerNames.add("surname");
headerNames.add("position");
headerNames.add("society");
headerNames.add("contact-type");
headerNames.add("channel");
headerNames.add("brand");
headerNames.add("detail-value");
orderableHeaders.put("name", "name");
orderableHeaders.put("surname", "surname");
orderableHeaders.put("society", "society");
orderableHeaders.put("contact-type", "contact-type");
}
public static final String EMPTY_RESULTS_MESSAGE = "no-contacts-were-found";
public ABContactSearch(PortletRequest portletRequest, PortletURL iteratorURL) {
super(
portletRequest, new ABContactDisplayTerms(portletRequest),
new ABContactSearchTerms(portletRequest), DEFAULT_CUR_PARAM,
DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);
ABContactDisplayTerms displayTerms = (ABContactDisplayTerms)getDisplayTerms();
iteratorURL.setParameter(
ABContactDisplayTerms.NAME, displayTerms.getName());
iteratorURL.setParameter(
ABContactDisplayTerms.SURNAME, displayTerms.getSurname());
iteratorURL.setParameter(
ABContactDisplayTerms.POSITION, displayTerms.getPosition());
iteratorURL.setParameter(
ABContactDisplayTerms.DETAIL_VALUE, displayTerms.getDetailValue());
iteratorURL.setParameter(
ABContactDisplayTerms.SOCIETY_ID, String.valueOf(displayTerms.getSocietyId()));
iteratorURL.setParameter(
ABContactDisplayTerms.CONTACT_TYPE_ID, String.valueOf(displayTerms.getContactTypeId()));
iteratorURL.setParameter(
ABContactDisplayTerms.BRAND_ID, String.valueOf(displayTerms.getBrandId()));
iteratorURL.setParameter(
ABContactDisplayTerms.CHANNEL_ID, String.valueOf(displayTerms.getChannelId()));
try {
String orderByCol = ParamUtil.getString(
portletRequest, "orderByCol", "surname");
String orderByType = ParamUtil.getString(
portletRequest, "orderByType", "asc");
// OrderByComparator orderByComparator =
// UsersAdminUtil.getUserOrderByComparator(
// orderByCol, orderByType);
setOrderableHeaders(orderableHeaders);
setOrderByCol(orderByCol);
setOrderByType(orderByType);
// setOrderByComparator(orderByComparator);
}
catch (Exception e) {
_log.error(e.getMessage());
_log.debug(e.getMessage(), e);
}
}
}
搜索容器本身运行良好,因为默认情况下使用空字符串执行基本搜索,但“搜索表单”未显示。我尝试将一些调试消息放在 contact_search_form.jsp 上,但它们都没有打印到控制台中。 taglib 似乎没有找到或处理该文件..
如有任何帮助,我们将不胜感激!
最佳答案
我的 100% 工作示例,其中使用 liferay-ui: search-container、liferay-ui: search-form 和 liferay-ui: search-toggle:
我的 100% 工作示例,其中使用 liferay-ui: search-container、liferay-ui: search-form 和 liferay-ui: search-toggle:view.jsp:
<%@ include file="/init.jsp" %>
<%
PortletURL portletURL = renderResponse.createRenderURL();
portletURL.setParameter("mvcPath", "/html/view.jsp");
pageContext.setAttribute("portletURL", portletURL);
%>
<aui:form name="searchForm" action="<%= portletURL.toString() %>" method="post">
<liferay-ui:search-container searchContainer="<%= new UserSearch(renderRequest, portletURL) %>" >
<aui:input disabled="<%= true %>" name="usersRedirect" type="hidden" value="<%= portletURL.toString() %>" />
<%
UserSearchTerms searchTerms = (UserSearchTerms)searchContainer.getSearchTerms();
UserDisplayTerms displayTerms = (UserDisplayTerms)searchContainer.getDisplayTerms();
long organizationId = searchTerms.getOrganizationId();
long userGroupId = searchTerms.getUserGroupId();
Organization organization = null;
if (organizationId > 0) {
try {
organization = OrganizationLocalServiceUtil.getOrganization(organizationId);
}
catch (NoSuchOrganizationException nsoe) {
}
}
UserGroup userGroup = null;
if (userGroupId > 0) {
try {
userGroup = UserGroupLocalServiceUtil.getUserGroup(userGroupId);
}
catch (NoSuchUserGroupException nsuge) {
}
}
%>
<c:if test="<%= organization != null %>">
<aui:input name="<%= UserDisplayTerms.ORGANIZATION_ID %>" type="hidden" value="<%= organization.getOrganizationId() %>" />
<h3><%= HtmlUtil.escape(LanguageUtil.format(pageContext, "users-of-x", organization.getName())) %></h3>
</c:if>
<c:if test="<%= userGroup != null %>">
<aui:input name="<%= UserDisplayTerms.USER_GROUP_ID %>" type="hidden" value="<%= userGroup.getUserGroupId() %>" />
<h3><%= LanguageUtil.format(pageContext, "users-of-x", HtmlUtil.escape(userGroup.getName())) %></h3>
</c:if>
<liferay-ui:search-form
page="/html/user_search.jsp"
searchContainer="<%= searchContainer %>"
servletContext="<%= this.getServletConfig().getServletContext() %>"
/>
<%
LinkedHashMap userParams = new LinkedHashMap();
if (organizationId > 0) {
userParams.put("usersOrgs", new Long(organizationId));
}
if (userGroupId > 0) {
userParams.put("usersUserGroups", new Long(userGroupId));
}
%>
<liferay-ui:search-container-results>
<c:choose>
<c:when test="<%= GetterUtil.getBoolean(PropsUtil.get(PropsKeys.USERS_INDEXER_ENABLED)) && GetterUtil.getBoolean(PropsUtil.get(PropsKeys.USERS_SEARCH_WITH_INDEX)) %>">
<%@ include file="/html/user_search_results_index.jspf" %>
</c:when>
<c:otherwise>
<%@ include file="/html/user_search_results_database.jspf" %>
</c:otherwise>
</c:choose>
</liferay-ui:search-container-results>
<liferay-ui:search-container-row
className="com.liferay.portal.model.User"
escapedModel="<%= true %>"
keyProperty="userId"
modelVar="curUser"
rowIdProperty="screenName"
>
<liferay-portlet:renderURL varImpl="rowURL" windowState="<%= WindowState.MAXIMIZED.toString() %>">
<portlet:param name="mvcPath" value="/html/user_display.jsp" />
<portlet:param name="redirect" value="<%= searchContainer.getIteratorURL().toString() %>" />
<portlet:param name="userId" value="<%= String.valueOf(curUser.getUserId()) %>" />
</liferay-portlet:renderURL>
<%@ include file="/html/search_columns.jspf" %>
</liferay-ui:search-container-row>
<c:if test="<%= (organization != null) || (userGroup != null) %>">
<br />
</c:if>
<c:if test="<%= organization != null %>">
<aui:input name="<%= UserDisplayTerms.ORGANIZATION_ID %>" type="hidden" value="<%= organization.getOrganizationId() %>" />
<liferay-ui:message key="filter-by-organization" />: <%= HtmlUtil.escape(organization.getName()) %><br />
</c:if>
<c:if test="<%= userGroup != null %>">
<aui:input name="<%= UserDisplayTerms.USER_GROUP_ID %>" type="hidden" value="<%= userGroup.getUserGroupId() %>" />
<liferay-ui:message key="filter-by-user-group" />: <%= HtmlUtil.escape(userGroup.getName()) %><br />
</c:if>
<div class="separator"><!-- --></div>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
</aui:form>
user_search.jsp:
<%@ include file="/init.jsp" %>
<%
UserSearch searchContainer = (UserSearch)request.getAttribute("liferay-ui:search:searchContainer");
UserDisplayTerms displayTerms = (UserDisplayTerms)searchContainer.getDisplayTerms();
%>
<liferay-ui:search-toggle
buttonLabel="search"
displayTerms="<%= displayTerms %>"
id="toggle_id_user_search"
>
<aui:fieldset>
<aui:input name="<%= displayTerms.FIRST_NAME %>" size="20" type="text" value="<%= displayTerms.getFirstName() %>" />
<aui:input name="<%= displayTerms.MIDDLE_NAME %>" size="20" type="text" value="<%= displayTerms.getMiddleName() %>" />
<aui:input name="<%= displayTerms.LAST_NAME %>" size="20" type="text" value="<%= displayTerms.getLastName() %>" />
<aui:input name="<%= displayTerms.SCREEN_NAME %>" size="20" type="text" value="<%= displayTerms.getScreenName() %>" />
<aui:input name="<%= displayTerms.EMAIL_ADDRESS %>" size="20" type="text" value="<%= displayTerms.getEmailAddress() %>" />
</aui:fieldset>
</liferay-ui:search-toggle>
user_search_results_index.jspf:
<%@ page import="com.liferay.portal.kernel.search.Hits" %>
<%@ page import="com.liferay.portal.kernel.search.Sort" %>
<%@ page import="com.liferay.portal.kernel.search.SortFactoryUtil" %>
<%@ page import="com.liferay.portlet.usersadmin.util.UsersAdminUtil" %>
<%
userParams.put("expandoAttributes", searchTerms.getKeywords());
Sort sort = SortFactoryUtil.getSort(User.class, searchContainer.getOrderByCol(), searchContainer.getOrderByType());
while (true) {
Hits hits = null;
if (searchTerms.isAdvancedSearch()) {
hits = UserLocalServiceUtil.search(company.getCompanyId(), searchTerms.getFirstName(), searchTerms.getMiddleName(), searchTerms.getLastName(), searchTerms.getScreenName(), searchTerms.getEmailAddress(), searchTerms.getStatus(), userParams, searchTerms.isAndOperator(), searchContainer.getStart(), searchContainer.getEnd(), sort);
}
else {
hits = UserLocalServiceUtil.search(company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getStatus(), userParams, searchContainer.getStart(), searchContainer.getEnd(), sort);
}
Tuple tuple = UsersAdminUtil.getUsers(hits);
boolean corruptIndex = (Boolean)tuple.getObject(1);
if (!corruptIndex) {
results = (List<User>)tuple.getObject(0);
total = hits.getLength();
break;
}
}
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
%>
user_search_results_database.jspf:
<%
if (searchTerms.isAdvancedSearch()) {
results = UserLocalServiceUtil.search(company.getCompanyId(), searchTerms.getFirstName(), searchTerms.getMiddleName(), searchTerms.getLastName(), searchTerms.getScreenName(), searchTerms.getEmailAddress(), searchTerms.getStatus(), userParams, searchTerms.isAndOperator(), searchContainer.getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator());
total = UserLocalServiceUtil.searchCount(company.getCompanyId(), searchTerms.getFirstName(), searchTerms.getMiddleName(), searchTerms.getLastName(), searchTerms.getScreenName(), searchTerms.getEmailAddress(), searchTerms.getStatus(), userParams, searchTerms.isAndOperator());
}
else {
results = UserLocalServiceUtil.search(company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getStatus(), userParams, searchContainer.getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator());
total = UserLocalServiceUtil.searchCount(company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getStatus(), userParams);
}
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
%>
user_display.jsp:
<%@ include file="/init.jsp" %>
<%
String backURL = ParamUtil.getString(request, "redirect");
portletDisplay.setURLBack(backURL);
long userId = ParamUtil.getLong(request, "userId");
%>
<liferay-ui:user-display
displayStyle="<%= 2 %>"
userId="<%= userId %>"
/>
search_columns.jspf:
<liferay-ui:search-container-column-text
href="<%= rowURL %>"
name="first-name"
orderable="<%= true %>"
property="firstName"
/>
<liferay-ui:search-container-column-text
href="<%= rowURL %>"
name="last-name"
orderable="<%= true %>"
property="lastName"
/>
<liferay-ui:search-container-column-text
href="<%= rowURL %>"
name="screen-name"
orderable="<%= true %>"
property="screenName"
/>
<liferay-ui:search-container-column-text
href="<%= rowURL %>"
name="organizations"
>
<liferay-ui:write bean="<%= curUser %>" property="organizations" />
</liferay-ui:search-container-column-text>
UserSearch.java:
package kz.b2e.kudos.portal.searchuser.search;
import com.liferay.portal.kernel.dao.search.SearchContainer;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.JavaConstants;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.model.User;
import com.liferay.portal.util.PortletKeys;
import com.liferay.portlet.PortalPreferences;
import com.liferay.portlet.PortletPreferencesFactoryUtil;
import com.liferay.portlet.usersadmin.util.UsersAdminUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.portlet.PortletConfig;
import javax.portlet.PortletRequest;
import javax.portlet.PortletURL;
public class UserSearch extends SearchContainer<User> {
static List<String> headerNames = new ArrayList<String>();
static Map<String, String> orderableHeaders = new HashMap<String, String>();
static {
headerNames.add("first-name");
headerNames.add("last-name");
headerNames.add("screen-name");
//headerNames.add("email-address");
headerNames.add("job-title");
headerNames.add("organizations");
orderableHeaders.put("first-name", "first-name");
orderableHeaders.put("last-name", "last-name");
orderableHeaders.put("screen-name", "screen-name");
//orderableHeaders.put("email-address", "email-address");
orderableHeaders.put("job-title", "job-title");
}
public static final String EMPTY_RESULTS_MESSAGE = "no-users-were-found";
public UserSearch(PortletRequest portletRequest, PortletURL iteratorURL) {
this(portletRequest, DEFAULT_CUR_PARAM, iteratorURL);
}
public UserSearch(
PortletRequest portletRequest, String curParam,
PortletURL iteratorURL) {
super(
portletRequest, new UserDisplayTerms(portletRequest),
new UserSearchTerms(portletRequest), curParam, DEFAULT_DELTA,
iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);
PortletConfig portletConfig =
(PortletConfig)portletRequest.getAttribute(
JavaConstants.JAVAX_PORTLET_CONFIG);
UserDisplayTerms displayTerms = (UserDisplayTerms)getDisplayTerms();
UserSearchTerms searchTerms = (UserSearchTerms)getSearchTerms();
String portletName = portletConfig.getPortletName();
if (!portletName.equals(PortletKeys.USERS_ADMIN)) {
displayTerms.setStatus(WorkflowConstants.STATUS_APPROVED);
searchTerms.setStatus(WorkflowConstants.STATUS_APPROVED);
}
iteratorURL.setParameter(
UserDisplayTerms.STATUS, String.valueOf(displayTerms.getStatus()));
iteratorURL.setParameter(
UserDisplayTerms.EMAIL_ADDRESS, displayTerms.getEmailAddress());
iteratorURL.setParameter(
UserDisplayTerms.FIRST_NAME, displayTerms.getFirstName());
iteratorURL.setParameter(
UserDisplayTerms.LAST_NAME, displayTerms.getLastName());
iteratorURL.setParameter(
UserDisplayTerms.MIDDLE_NAME, displayTerms.getMiddleName());
iteratorURL.setParameter(
UserDisplayTerms.ORGANIZATION_ID,
String.valueOf(displayTerms.getOrganizationId()));
iteratorURL.setParameter(
UserDisplayTerms.ROLE_ID, String.valueOf(displayTerms.getRoleId()));
iteratorURL.setParameter(
UserDisplayTerms.SCREEN_NAME, displayTerms.getScreenName());
iteratorURL.setParameter(
UserDisplayTerms.USER_GROUP_ID,
String.valueOf(displayTerms.getUserGroupId()));
try {
PortalPreferences preferences =
PortletPreferencesFactoryUtil.getPortalPreferences(
portletRequest);
String orderByCol = ParamUtil.getString(
portletRequest, "orderByCol");
String orderByType = ParamUtil.getString(
portletRequest, "orderByType");
if (Validator.isNotNull(orderByCol) &&
Validator.isNotNull(orderByType)) {
preferences.setValue(
PortletKeys.USERS_ADMIN, "users-order-by-col", orderByCol);
preferences.setValue(
PortletKeys.USERS_ADMIN, "users-order-by-type",
orderByType);
}
else {
orderByCol = preferences.getValue(
PortletKeys.USERS_ADMIN, "users-order-by-col", "last-name");
orderByType = preferences.getValue(
PortletKeys.USERS_ADMIN, "users-order-by-type", "asc");
}
OrderByComparator orderByComparator =
UsersAdminUtil.getUserOrderByComparator(
orderByCol, orderByType);
setOrderableHeaders(orderableHeaders);
setOrderByCol(orderByCol);
setOrderByType(orderByType);
setOrderByComparator(orderByComparator);
}
catch (Exception e) {
_log.error(e);
}
}
private static Log _log = LogFactoryUtil.getLog(UserSearch.class);
}
UserSearchTerms.java:
package kz.b2e.kudos.portal.searchuser.search;
import com.liferay.portal.kernel.dao.search.SearchContainer;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.JavaConstants;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.model.User;
import com.liferay.portal.util.PortletKeys;
import com.liferay.portlet.PortalPreferences;
import com.liferay.portlet.PortletPreferencesFactoryUtil;
import com.liferay.portlet.usersadmin.util.UsersAdminUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.portlet.PortletConfig;
import javax.portlet.PortletRequest;
import javax.portlet.PortletURL;
public class UserSearch extends SearchContainer<User> {
static List<String> headerNames = new ArrayList<String>();
static Map<String, String> orderableHeaders = new HashMap<String, String>();
static {
headerNames.add("first-name");
headerNames.add("last-name");
headerNames.add("screen-name");
//headerNames.add("email-address");
headerNames.add("job-title");
headerNames.add("organizations");
orderableHeaders.put("first-name", "first-name");
orderableHeaders.put("last-name", "last-name");
orderableHeaders.put("screen-name", "screen-name");
//orderableHeaders.put("email-address", "email-address");
orderableHeaders.put("job-title", "job-title");
}
public static final String EMPTY_RESULTS_MESSAGE = "no-users-were-found";
public UserSearch(PortletRequest portletRequest, PortletURL iteratorURL) {
this(portletRequest, DEFAULT_CUR_PARAM, iteratorURL);
}
public UserSearch(
PortletRequest portletRequest, String curParam,
PortletURL iteratorURL) {
super(
portletRequest, new UserDisplayTerms(portletRequest),
new UserSearchTerms(portletRequest), curParam, DEFAULT_DELTA,
iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);
PortletConfig portletConfig =
(PortletConfig)portletRequest.getAttribute(
JavaConstants.JAVAX_PORTLET_CONFIG);
UserDisplayTerms displayTerms = (UserDisplayTerms)getDisplayTerms();
UserSearchTerms searchTerms = (UserSearchTerms)getSearchTerms();
String portletName = portletConfig.getPortletName();
if (!portletName.equals(PortletKeys.USERS_ADMIN)) {
displayTerms.setStatus(WorkflowConstants.STATUS_APPROVED);
searchTerms.setStatus(WorkflowConstants.STATUS_APPROVED);
}
iteratorURL.setParameter(
UserDisplayTerms.STATUS, String.valueOf(displayTerms.getStatus()));
iteratorURL.setParameter(
UserDisplayTerms.EMAIL_ADDRESS, displayTerms.getEmailAddress());
iteratorURL.setParameter(
UserDisplayTerms.FIRST_NAME, displayTerms.getFirstName());
iteratorURL.setParameter(
UserDisplayTerms.LAST_NAME, displayTerms.getLastName());
iteratorURL.setParameter(
UserDisplayTerms.MIDDLE_NAME, displayTerms.getMiddleName());
iteratorURL.setParameter(
UserDisplayTerms.ORGANIZATION_ID,
String.valueOf(displayTerms.getOrganizationId()));
iteratorURL.setParameter(
UserDisplayTerms.ROLE_ID, String.valueOf(displayTerms.getRoleId()));
iteratorURL.setParameter(
UserDisplayTerms.SCREEN_NAME, displayTerms.getScreenName());
iteratorURL.setParameter(
UserDisplayTerms.USER_GROUP_ID,
String.valueOf(displayTerms.getUserGroupId()));
try {
PortalPreferences preferences =
PortletPreferencesFactoryUtil.getPortalPreferences(
portletRequest);
String orderByCol = ParamUtil.getString(
portletRequest, "orderByCol");
String orderByType = ParamUtil.getString(
portletRequest, "orderByType");
if (Validator.isNotNull(orderByCol) &&
Validator.isNotNull(orderByType)) {
preferences.setValue(
PortletKeys.USERS_ADMIN, "users-order-by-col", orderByCol);
preferences.setValue(
PortletKeys.USERS_ADMIN, "users-order-by-type",
orderByType);
}
else {
orderByCol = preferences.getValue(
PortletKeys.USERS_ADMIN, "users-order-by-col", "last-name");
orderByType = preferences.getValue(
PortletKeys.USERS_ADMIN, "users-order-by-type", "asc");
}
OrderByComparator orderByComparator =
UsersAdminUtil.getUserOrderByComparator(
orderByCol, orderByType);
setOrderableHeaders(orderableHeaders);
setOrderByCol(orderByCol);
setOrderByType(orderByType);
setOrderByComparator(orderByComparator);
}
catch (Exception e) {
_log.error(e);
}
}
private static Log _log = LogFactoryUtil.getLog(UserSearch.class);
}
UserDisplayTerms.java
package kz.b2e.kudos.portal.searchuser.search;
import com.liferay.portal.kernel.dao.search.DisplayTerms;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import javax.portlet.PortletRequest;
public class UserDisplayTerms extends DisplayTerms {
public static final String EMAIL_ADDRESS = "emailAddress";
public static final String FIRST_NAME = "firstName";
public static final String LAST_NAME = "lastName";
public static final String MIDDLE_NAME = "middleName";
public static final String ORGANIZATION_ID = "organizationId";
public static final String ROLE_ID = "roleId";
public static final String SCREEN_NAME = "screenName";
public static final String STATUS = "status";
public static final String USER_GROUP_ID = "userGroupId";
public UserDisplayTerms(PortletRequest portletRequest) {
super(portletRequest);
String statusString = ParamUtil.getString(portletRequest, STATUS);
if (Validator.isNotNull(statusString)) {
status = GetterUtil.getInteger(statusString);
}
emailAddress = ParamUtil.getString(portletRequest, EMAIL_ADDRESS);
firstName = ParamUtil.getString(portletRequest, FIRST_NAME);
lastName = ParamUtil.getString(portletRequest, LAST_NAME);
middleName = ParamUtil.getString(portletRequest, MIDDLE_NAME);
organizationId = ParamUtil.getLong(portletRequest, ORGANIZATION_ID);
roleId = ParamUtil.getLong(portletRequest, ROLE_ID);
screenName = ParamUtil.getString(portletRequest, SCREEN_NAME);
userGroupId = ParamUtil.getLong(portletRequest, USER_GROUP_ID);
}
public String getEmailAddress() {
return emailAddress;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public String getMiddleName() {
return middleName;
}
public long getOrganizationId() {
return organizationId;
}
public long getRoleId() {
return roleId;
}
public String getScreenName() {
return screenName;
}
public int getStatus() {
return status;
}
public long getUserGroupId() {
return userGroupId;
}
public boolean isActive() {
if (status == WorkflowConstants.STATUS_APPROVED) {
return true;
}
else {
return false;
}
}
public void setStatus(int status) {
this.status = status;
}
protected String emailAddress;
protected String firstName;
protected String lastName;
protected String middleName;
protected long organizationId;
protected long roleId;
protected String screenName;
protected int status;
protected long userGroupId;
}
关于Liferay liferay-ui :search-toggle not showing (on search-form),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12623602/
我有一个扩展程序,我已经拆掉了裸机,它使自己处于不正确的状态,当它折叠时它会说“显示更少”。 这有两种情况 我使用“显示更多”展开扩展,然后离开屏幕。我打开另一个应用程序,然后返回到扩展程序。扩展的扩
为什么这些不相等? show $ if someCondition then someInt else some double 和 if someCondition then show someInt
下面给出的代码可以编译,ok。 data Car p q r = Car {company :: p , model :: q
是否可以在表结构中的“显示 0 到 0 个条目中的 0 个条目”旁边显示“显示条目”下拉列表。我想在底部显示“显示条目”下拉列表以及分页并显示 0 到 0 个条目,共 0 个条目。 提前致谢!!! 图
我不明白当你这样做一连串 .show() 时会发生什么。我也没有编写这段代码,也不知道如何弄清楚这里发生了什么。因此就有了这个问题。 // Remove favorite category
$(document).ready(function(){ $('html').addClass('js'); var contactForm = {
因此,在实现上一个问题的 jQuery 代码后,我注意到以下内容,每当人们添加位于显示较少/显示更多菜单中的产品时,系统会刷新页面,因为它会重新计算价格,因此也会刷新页面。但是当发生这种情况时,菜单会
我已经在 Windows 上设置了 mongodb 64bits。我成功运行了服务器和客户端。 但是当我输入时: show dbs 输出是 local 0.000GB 为什么? show dbs 应
正如标题所说,我有兴趣使用 Show a在我有 Show (a,b) 的情况下. GADT 很容易出现这个问题,如下所示: data PairOrNot a where Pair :: (b,c)
通常 julia> Base.show(io::IO, a::Int) = print(io, "xx") show (generic function with 98 methods) julia>
通常 julia> Base.show(io::IO, a::Int) = print(io, "xx") show (generic function with 98 methods) julia>
我找不到关于 Readline 选项 show-all-if-ambiguous 和 show-all-if-unmodified 之间区别的明确解释,以及是否它们影响不同的事物或相互排斥。关于这个主
我是 BeautifulSoup 的新手,我遇到了一些我不明白的问题,我认为这个问题可能尚未得到解答,但在这种情况下,我找到的答案都没有帮助我。 我需要访问 div 的内部以检索网站的词汇表条目,但是
我已经为 iOS 10 实现了新的小部件,并使用以下代码为其设置高度: @available(iOSApplicationExtension 10.0, *) func widgetActiveDis
克隆远程 git 存储库并发出 git show --show-signature 后,它说签名是好的。然后我更改了一些文件并测试了相同的命令,它仍然说签名是好的。 上面的命令到底检查了什么?验证克隆
我陷入了这个问题,而且我对 Haskell 很陌生,我试图用以下代码完成第一个欧拉问题: main = putStrLn . show . sum $ [3,6..1000]:[5,10..1000]
我有一个独立的 Android 和 iOS 应用程序。 目前正在 Android 上测试推送通知。 我已经使用以下通知键设置了我的 app.json "notification":{ "i
我所说的示例:http://jsfiddle.net/bsnxp/1/ 如果你检查源 .show().clone() display 是 inline-block (它应该是什么)并且 .clone(
我正在使用下面的 jQuery 代码来显示/隐藏网页上的额外文本 jQuery.fn.shorten = function(settings) { var config = { showC
我有一个带有 ng-show 的 div。这个 div 是我创建的自定义指令的包装器。 HTML JS function myDirective() { function doS
我是一名优秀的程序员,十分优秀!