use of com.iplanet.jato.view.html.OptionList in project OpenAM by OpenRock.
the class EntityEditViewBean method getOptionListForEntities.
protected OptionList getOptionListForEntities(Collection entities) {
OptionList optList = new OptionList();
if ((entities != null) && !entities.isEmpty()) {
EntitiesModel model = (EntitiesModel) getModel();
Map lookup = new HashMap(entities.size() * 2);
Set unsorted = new HashSet(entities.size() * 2);
for (Iterator iter = entities.iterator(); iter.hasNext(); ) {
AMIdentity entity = (AMIdentity) iter.next();
String name = AMFormatUtils.getIdentityDisplayName(model, entity);
String universalId = IdUtils.getUniversalId(entity);
lookup.put(universalId, name);
unsorted.add(name);
}
List list = AMFormatUtils.sortItems(unsorted, model.getUserLocale());
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
String name = (String) iter.next();
String id = null;
String tmp = null;
for (Iterator it = lookup.keySet().iterator(); it.hasNext(); ) {
id = (String) it.next();
if (lookup.get(id).equals(name)) {
tmp = name + "(" + LDAPUtils.rdnValueFromDn(id) + ")";
optList.add(tmp, id);
}
}
}
}
return optList;
}
use of com.iplanet.jato.view.html.OptionList in project OpenAM by OpenRock.
the class AMViewBeanBase method createOptionList.
/**
* Returns an option list object that contains options for a given
* collection of string.
*
* @param collection Collection of strings to be included in option list.
* @return a option list object that contains options for a given
* collection of string.
*/
public OptionList createOptionList(Collection collection) {
OptionList optionList = new OptionList();
if ((collection != null) && !collection.isEmpty()) {
// first sort the entries in the collection
collection = AMFormatUtils.sortItems(collection, getModel().getUserLocale());
for (Iterator iter = collection.iterator(); iter.hasNext(); ) {
String value = (String) iter.next();
optionList.add(value, value);
}
}
return optionList;
}
use of com.iplanet.jato.view.html.OptionList in project OpenAM by OpenRock.
the class AMViewBeanBase method createOptionList.
// End of Abstract Methods ------------------------------------------------
/**
* Returns a option list object that contains options for a given map
* of value to its localized string.
*
* @param map Map of value to its localized string.
* @return a option list object that contains options for a given map
* of value to its localized string.
*/
public OptionList createOptionList(Map map) {
OptionList optionList = new OptionList();
if ((map != null) && !map.isEmpty()) {
List sorted = AMFormatUtils.sortItems(map.values(), getModel().getUserLocale());
Map reversed = AMFormatUtils.reverseStringMap(map);
for (Iterator iter = sorted.iterator(); iter.hasNext(); ) {
String label = (String) iter.next();
optionList.add(label, (String) reversed.get(label));
}
}
return optionList;
}
use of com.iplanet.jato.view.html.OptionList in project OpenAM by OpenRock.
the class AMViewBeanBase method getList.
/**
* Returns a list of string from a option list items.
*
* @param optList Option list that contains the items.
* @return list of string from a option list items.
*/
public static List getList(OptionList optList) {
int sz = optList.size();
List list = new ArrayList(sz);
for (int i = 0; i < sz; i++) {
list.add(optList.getValue(i));
}
return list;
}
use of com.iplanet.jato.view.html.OptionList in project OpenAM by OpenRock.
the class SubSchemaTypeSelectViewBean method beginDisplay.
public void beginDisplay(DisplayEvent event) throws ModelControlException {
super.beginDisplay(event);
SubConfigModel model = (SubConfigModel) getModel();
Map createables = model.getCreateableSubSchemaNames();
CCRadioButton rb = (CCRadioButton) getChild(RB_SUBCONFIG);
OptionList optList = AMFormatUtils.getSortedOptionList(createables, model.getUserLocale());
rb.setOptions(optList);
String val = (String) rb.getValue();
if ((val == null) || (val.length() == 0)) {
rb.setValue(optList.getValue(0));
}
}
Aggregations