Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
raghu N M
query on UserLocalServiceUtil.search
15 de Março de 2011 12:56
Resposta

raghu N M

Ranking: Junior Member

Mensagens: 27

Data de entrada: 27 de Julho de 2010

Mensagens recentes

Hello Development team,
find the below code.
When I pass name as null or empty, i get the resultset. If I pass any other name it gives empty results. May I know what i am doing wrong.

Thanks in advance,
Sincerely yours,
Raghu NM



<%
boolean asc = true;
Sort sort = new Sort("lastName", Sort.STRING_TYPE, asc);
LinkedHashMap userParams = new LinkedHashMap();
userParams.put("expandoAttributes","");
List<User> list = new ArrayList<User>();
Hits hits = UserLocalServiceUtil.search(company.getCompanyId(),name, name, name, name, name, true, userParams, true, 0, 20, sort);
list = _getResults(hits);

if(list != null)
{
%>

<liferay-ui:search-container emptyResultsMessage="publisher-empty-results-message">
<liferay-ui:search-container-results
results="<%=list%>"
/>
<liferay-ui:search-container-row
className="com.liferay.portal.model.User"
keyProperty="userId"
modelVar="user"
>
</liferay-ui:search-container-row>

<liferay-ui:search-iterator />
</liferay-ui:search-container>
<%
}

%>
<%!
<%!
private static List<User> _getResults(Hits hits) throws Exception {
List<User> users = new ArrayList<User>();

List<Document> hitsList = hits.toList();
for (Document doc : hitsList) {
long userId = GetterUtil.getLong(doc.get(Field.USER_ID));

try {
users.add(UserLocalServiceUtil.getUserById(userId));
}
catch (Exception nsue) {

}
}

return users;
}
%>
raghu N M
RE: query on UserLocalServiceUtil.search
16 de Março de 2011 09:11
Resposta

raghu N M

Ranking: Junior Member

Mensagens: 27

Data de entrada: 27 de Julho de 2010

Mensagens recentes

If I use this search method, it works fine.

Hits hits = UserLocalServiceUtil.search(company.getCompanyId(), name, true, userParams, 0, 20, sort);

but this doesn't work for advance search ?