/** * If the property is a {@link ListClass}, returns the possible values as a map {@code internal key <-> displayed * value}. * * @return the map of possible ({@code String}) values and their associated ({@code ListItem}) displayed values * @see #getListValues() {@code getListValues()} returns only the list of possible internal keys **/ public Map<String, ListItem> getMapValues() { com.xpn.xwiki.objects.classes.PropertyClass pclass = getBasePropertyClass(); if (pclass instanceof ListClass) { return ((ListClass) pclass).getMap(this.context); } else { // Although we prefer to return empty maps from API methods, here returning any kind of map 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(); }
@Override public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) { List<String> selectlist; String separator = getSeparator(); BaseProperty prop = (BaseProperty) object.safeget(name); Map<String, ListItem> map = getMap(context); // Skip unset values. if (prop == null) { return; } if (prop instanceof ListProperty) { selectlist = ((ListProperty) prop).getList(); List<String> newlist = new ArrayList<String>(); for (String value : selectlist) { newlist.add(getDisplayValue(value, name, map, context)); } buffer.append(StringUtils.join(newlist, separator)); } else { buffer.append(getDisplayValue(prop.getValue(), name, map, context)); } }
Map<String, ListItem> map = getMap(context); List<String> selectlist;
Map<String, ListItem> map = getMap(context);
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(); }