DirectoryPopup.java
From LongJump Support Wiki
Revision as of 23:43, 20 December 2010 by imported>Aeric (Text replace - 'import static com.platform.api.Functions.*; ' to '')
import com.platform.api.*; public class DirectoryPopup { // Initialize the custom object ID - this can be obtained after creating the object // Search Record // Functions.searchRecords(String objectId, String fields, String criteria, // String sortBy, String sortOrder, String sortBy2, // String sortOrder2, int offset, int numberOfRows) public Result search(HashMap params) throws Exception { Functions.debug(params); String objectId = (String)params.get("object_id"); if(objectId == null ) objectId = ""; String sort_by = (String)params.get("sort_by"); if(sort_by == null || sort_by.equals("")) sort_by = "name"; String sort_order = (String)params.get("sort_order"); if(sort_order == null || sort_order.equals("")) sort_order = "asc"; String no_of_rows = (String)params.get("no_of_rows"); if(no_of_rows == null || no_of_rows.equals("")) no_of_rows = "10"; String offset = (String)params.get("offset"); if(offset == null || offset.equals("")) offset = "0"; String searchType = (String)params.get("searchType"); if(searchType == null ) searchType = "name"; String keyword= (String)params.get("keyword"); if(keyword== null ) keyword= ""; Result result = null; if(searchType != null && !searchType.equals("")) { if(keyword== null ||keyword.equals("")) { result = Functions.searchRecords(objectId, "record_id,first_name,name1,address,city,state,zip,direct_phone,email", "", sort_by, sort_order, "", "", Integer.parseInt(offset), Integer.parseInt(no_of_rows)); } else { result = Functions.searchRecords(objectId, "record_id,first_name,name1,address,city,state,zip,direct_phone,email", searchType + " contains '" + keyword+ "'", sort_by, sort_order, "", "", Integer.parseInt(offset), Integer.parseInt(no_of_rows)); } } else { result = Functions.searchRecords(objectId, "record_id,first_name,name1,address,city,state,zip,direct_phone,email", "", sort_by, sort_order, "", "", Integer.parseInt(offset), Integer.parseInt(no_of_rows)); } return result; } }