/** * If the property is a {@link ListClass}, returns the possible values. These are the internal values (keys), and * not the user-friendly or translated values that would be displayed to the user. * * @return the list of possible ({@code String}) values * @see #getMapValues() {@code getMapValues()} returns both the keys and their user-friendly displayed values **/ public List<String> getListValues() { com.xpn.xwiki.objects.classes.PropertyClass pclass = getBasePropertyClass(); if (pclass instanceof ListClass) { return ((ListClass) pclass).getList(this.context); } else { // Although we prefer to return empty lists from API methods, here returning any kind of list doesn't make // sense, since the property does not have a list of possible values at all (like, a number property). return null; } }
protected String displayRadioSearch(String name, String prefix, XWikiCriteria criteria, XWikiContext context) { StringBuffer buffer = new StringBuffer(); List<String> list = getList(context); List<String> selectlist = new ArrayList<String>(); /* * BaseProperty prop = (BaseProperty)object.safeget(name); if (prop==null) { selectlist = new ArrayList(); } * else if ((prop instanceof ListProperty)||(prop instanceof DBStringListProperty)) { selectlist = (List) * prop.getValue(); } else { selectlist = new ArrayList(); selectlist.add(prop.getValue()); } */ // Add options from Set for (Iterator<String> it = list.iterator(); it.hasNext();) { String rawvalue = it.next(); String value = getElementValue(rawvalue); String display = getDisplayValue(rawvalue, name, getMap(context), context); input radio = new input(getDisplayType().equals("radio") ? input.radio : input.checkbox, prefix + name, value); if (selectlist.contains(value)) { radio.setChecked(true); } radio.addElement(display); buffer.append(radio.toString()); if (it.hasNext()) { buffer.append("<br/>"); } } return buffer.toString(); }
protected void displayRadioEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) List<String> list = getList(context); Map<String, ListItem> map = getMap(context); List<String> selectlist;
select.setDisabled(isDisabled()); List<String> list = getList(context); Map<String, ListItem> map = getMap(context);
ListClass listClass = (ListClass) propertyClass; List allowedValueList = listClass.getList(xwikiContext);
protected String displaySelectSearch(String name, String prefix, XWikiCriteria criteria, XWikiContext context) { select select = new select(prefix + name, 1); select.setMultiple(true); select.setSize(5); select.setName(prefix + name); select.setID(prefix + name); List<String> list = getList(context); String fieldFullName = getFieldFullName(); String[] selectArray = ((String[]) criteria.getParameter(fieldFullName)); List<String> selectlist = (selectArray != null) ? Arrays.asList(selectArray) : new ArrayList<String>(); /* * BaseProperty prop = (BaseProperty)object.safeget(name); if (prop==null) { selectlist = new ArrayList(); } * else if ((prop instanceof ListProperty)||(prop instanceof DBStringListProperty)) { selectlist = (List) * prop.getValue(); } else { selectlist = new ArrayList(); selectlist.add(prop.getValue()); } */ // Add options from Set for (String rawvalue : list) { String value = getElementValue(rawvalue); String display = getDisplayValue(rawvalue, name, getMap(context), context); option option = new option(display, value); option.addElement(display); if (selectlist.contains(value)) { option.setSelected(true); } select.addElement(option); } return select.toString(); }
result.setPropertyAllowedValues(propertyName, listClass.getList(xwikiContext));