public Object getTypeAheadSimpleValue(UITypeAhead typeAhead) { IPickerData dp = getDataProvider(); if (dp != null) { int max = typeAhead.getMaxValues(); if (max <= 0) { max = Integer.MAX_VALUE; } max = Math.min(max, 50); // Put a limit for now... // How to get isMultipleTrim here? String value = getStartsValue(FacesContext.getCurrentInstance(), typeAhead, true); // Use the Key and not the startKey to filter the right set of // values int source = 0; // Always the first source? SimplePickerOptions options = new SimplePickerOptions(source, 0, max, value, null, null); IPickerResult r = dp.readEntries(options); List<IPickerEntry> entries = r.getEntries(); Object[] res = new Object[entries.size()]; for (int i = 0; i < res.length; i++) { res[i] = entries.get(i).getValue(); } return res; } return null; }
public Object getTypeAheadMarkupValue(UITypeAhead typeAhead) { IPickerData dp = getDataProvider(); if (dp != null) { int max = typeAhead.getMaxValues(); if (max <= 0) { max = Integer.MAX_VALUE; } max = Math.min(max, 50); // Put a limit for now... // Read the entry String value = getStartsValue(FacesContext.getCurrentInstance(), typeAhead, true); // Use the Key and not the startKey to filter the right set of // values int source = 0; // Always the first source? SimplePickerOptions options = new SimplePickerOptions(source, 0, max, value, null, null); IPickerResult r = dp.readEntries(options); List<IPickerEntry> entries = r.getEntries(); StringBuilder b = new StringBuilder(); b.append("<ul>"); // $NON-NLS-1$ int sz = entries.size(); for (int i = 0; i < sz; i++) { IPickerEntry e = entries.get(i); Object val = e.getValue(); if (value != null) { b.append("<li>"); // $NON-NLS-1$ Object label = e.getLabel(); if (label != null) { // Note, use double-quotes instead of single-quotes for // attributes, so as to be XHTML-compliant. b.append("<span class=\"informal\">"); // $NON-NLS-1$ b.append(TextUtil.toXMLString(label.toString())); b.append("</span>"); // $NON-NLS-1$ } b.append(TextUtil.toXMLString(val.toString())); b.append("</li>"); // $NON-NLS-1$ } } b.append("</ul>"); // $NON-NLS-1$ return b.toString(); } return null; }