public boolean listIsEmpty() { NSArray list = found; if (list != null && list.count() > 0) return false; list = (NSArray) valueForBinding("forcedList"); if (list != null && list.count() > 0) return false; list = personList(); if (list != null && list.count() > 0) return false; return true; }
protected PersonLink defaultSelectionValue() { NSArray list = (NSArray) valueForBinding("forcedList"); if (list != null && list.count() > 0) { return (PersonLink) EOUtilities.localInstanceOfObject(ec, (EOEnterpriseObject) list.objectAtIndex(0)); } list = (NSArray) session().valueForKey("personList"); if (list != null && list.count() > 0) { Enumeration enu = list.objectEnumerator(); while (enu.hasMoreElements()) { EOEnterpriseObject pers = (EOEnterpriseObject) enu.nextElement(); if (entity().equals(pers.entityName())) { return (PersonLink) pers; } } } return null; }
public WOActionResults submit() { if (selection == null) { search(); if (found != null && found.count() > 0) { selection = (PersonLink) found.objectAtIndex(0); } else { selection = defaultSelectionValue(); } } setValueForBinding(selection, "selection"); return (WOActionResults) valueForBinding("selectAction"); }
public void search() { try { found = Person.Utility.search(ec, entity(), searchString); if ((found == null || found.count() == 0) && alterEntity() != null) found = Person.Utility.search(ec, alterEntity(), searchString); } catch (Exception e) { searchMessage = e.getMessage(); canCreate = false; return; } if (found.count() < 1) { searchMessage = (String) session().valueForKeyPath("strings.Strings.messages.nothingFound"); canCreate = Various.boolForObject(session().valueForKeyPath("readAccess.create." + entity())); return; } NSMutableArray fullList = (NSMutableArray) session().valueForKey("personList"); NSMutableArray tmp = found.mutableClone(); tmp.removeObjectsInArray(fullList); fullList.addObjectsFromArray(tmp); if (fullList.count() > 1) EOSortOrdering.sortArrayUsingKeyOrderArray(fullList, Person.sorter); searchMessage = null; }
public NSArray personList() { NSArray forcedList = (NSArray) valueForBinding("forcedList"); NSMutableArray result = (forcedList == null) ? new NSMutableArray() : EOUtilities.localInstancesOfObjects(ec, forcedList).mutableClone(); NSArray personList = (NSArray) session().valueForKey("personList"); if (personList != null && personList.count() > 0) { Enumeration enu = personList.objectEnumerator(); while (enu.hasMoreElements()) { EOEnterpriseObject pers = (EOEnterpriseObject) enu.nextElement(); if (!result.contains(pers) && (entity().equals(pers.entityName()) || pers.entityName().equals(alterEntity()))) result.addObject(pers); } } return result; }
protected void performSearchRequest(String request) { searchString = request; canCreate = false; search(); while (found == null || found.count() == 0) { searchString = searchString.substring(0, searchString.length() - 1); if (searchString.length() < 2) { searchString = request; setValueForBinding(null, "searchRequest"); return; } search(); } selection = (PersonLink) found.objectAtIndex(0); setValueForBinding(selection, "selection"); setValueForBinding(Person.Utility.fullName(selection, true, 2, 2, 2), "searchRequest"); valueForBinding("selectAction"); }