Last active
December 18, 2015 23:59
Search Conatiner UserUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UserUtil | |
{ | |
/** | |
* @param renderRequest | |
* @param renderResponse | |
*/ | |
public static void searchContainerData(RenderRequest renderRequest,RenderResponse renderResponse) | |
{ | |
PortletConfig portletConfig = (PortletConfig)renderRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); | |
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY); | |
List<user> userList = new ArrayList<user>(); | |
Map<String,String> paramMap= new HashMap<String,String>(); | |
paramMap.put("tabs", "User"); | |
/* | |
* Creating IteratorURL and in that we will pass tab parameter | |
*/ | |
PortletURL iteratorURL= renderResponse.createRenderURL(); | |
Iterator<Map.Entry<String, String>> entries = paramMap.entrySet().iterator(); | |
while (entries.hasNext()) { | |
Map.Entry<String, String> entry = entries.next(); | |
iteratorURL.setParameter(entry.getKey(), entry.getValue()); | |
} | |
/* | |
* Creating SearchContainer | |
*/ | |
SearchContainer<user> searchContainer = new SearchContainer<user>(renderRequest, null, | |
null, SearchContainer.DEFAULT_CUR_PARAM, ParamUtil.getInteger(renderRequest, SearchContainer.DEFAULT_DELTA_PARAM, 10), | |
iteratorURL, null, LanguageUtil.get(portletConfig, themeDisplay.getLocale(), "No Users were Found")); | |
int total = 0; | |
try { | |
/* | |
* Fetching all the User from the Current Company and added that into the userList | |
*/ | |
userList = UserLocalServiceUtil.getCompanyUsers(themeDisplay.getCompanyId(), -1, -1); | |
total = userList.size(); | |
} catch (SystemException e) { | |
SessionErrors.add(renderRequest, SystemException.class.getName()); | |
} | |
/* | |
* Sub listing the userList depending on the delta parameter we have set in the SearchContainer. | |
*/ | |
userList = ListUtil.subList(userList, searchContainer.getStart(), searchContainer.getEnd()); | |
searchContainer.setTotal(total); | |
searchContainer.setResults(userList); | |
renderRequest.setAttribute("userSearchContainer", searchContainer); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment