use of com.sun.web.ui.view.editablelist.CCEditableList in project OpenAM by OpenRock.
the class AMPropertySheetModel method createChild.
public View createChild(View parent, String name, AMModel model) {
String tagName = (String) childMap.get(name);
View view = null;
if (tagName != null) {
if (tagName.equals(ORDERED_LIST)) {
CCOrderedListModel m = new CCOrderedListModel();
view = new CCOrderedList((ContainerView) parent, m, name);
m.setAddButtonLabel(model.getLocalizedString("addremove.orderable.list.add.button"));
m.setDeleteButtonLabel(model.getLocalizedString("addremove.orderable.list.delete.button"));
setModel(name, m);
} else if (tagName.equals(UNORDERED_LIST)) {
CCUnOrderedListModel m = new CCUnOrderedListModel();
view = new CCUnOrderedList((ContainerView) parent, m, name);
setModel(name, m);
} else if (tagName.equals(MAP_LIST) || tagName.equals(GLOBAL_MAP_LIST)) {
CCMapListModel m = new CCMapListModel();
view = new CCMapList((ContainerView) parent, m, name);
m.setValueOptionList(mapOptionList.get(name));
m.setKeyLabel(model.getLocalizedString("maplist.key.label"));
m.setValueLabel(model.getLocalizedString("maplist.value.label"));
m.setMsgInvalidEntry(model.getLocalizedString("maplist.msg.invalid.entry"));
m.setMsgInvalidKey(model.getLocalizedString("maplist.msg.invalid.key"));
m.setMsgInvalidValue(model.getLocalizedString("maplist.msg.invalid.value"));
m.setMsgInvalidNoKey(model.getLocalizedString("maplist.msg.invalid.nokey"));
setModel(name, m);
} else if (tagName.equals(ADDREMOVE_LIST)) {
CCAddRemoveModel m = (CCAddRemoveModel) getModel(name);
if (m == null) {
setModel(name, new CCAddRemoveModel());
}
}
}
if (view == null) {
view = super.createChild(parent, name);
}
if (CCEditableList.class.isInstance(view)) {
CCEditableList editable = (CCEditableList) view;
CCEditableListModel m = (CCEditableListModel) editable.getModel();
m.setAddBtnLabel(model.getLocalizedString("editableList.addButtonLabel"));
m.setRemoveBtnLabel(model.getLocalizedString("editableList.deleteButtonLabel"));
}
children.add(view);
return view;
}
use of com.sun.web.ui.view.editablelist.CCEditableList in project OpenAM by OpenRock.
the class ServerEditViewBeanBase method getAttributeValues.
protected Map<String, String> getAttributeValues() {
Map<String, String> map = new HashMap<String, String>();
for (String uiName : activePropertyNames) {
View view = getChild(uiName);
String value;
if (view instanceof CCEditableList) {
CCEditableList list = (CCEditableList) view;
list.restoreStateData();
// Create a comma delimited String from the items in the OptionList for storage.
value = StringUtils.join(getValues(list.getModel().getOptionList()), ",");
} else {
value = (String) getDisplayFieldValue(uiName);
}
String propertyName = getActualPropertyName(uiName);
if (view instanceof CCCheckBox) {
value = (value.equals("true")) ? ServerPropertyValidator.getTrueValue(propertyName) : ServerPropertyValidator.getFalseValue(propertyName);
}
if (view instanceof CCPassword) {
// encrypt and include in the map of attribute values to save
if (!AMPropertySheetModel.passwordRandom.equals(value)) {
value = AccessController.doPrivileged(new EncodeAction(value));
map.put(propertyName, value);
}
} else {
map.put(propertyName, value);
}
}
return map;
}
use of com.sun.web.ui.view.editablelist.CCEditableList in project OpenAM by OpenRock.
the class ServerEditViewBeanBase method setConfigProperties.
private void setConfigProperties(String serverName, ServerSiteModel model) throws AMConsoleException {
if (!submitCycle) {
Map attributeValues = model.getServerConfiguration(serverName);
for (String name : activePropertyNames) {
String propertyName = getActualPropertyName(name);
String val = (String) attributeValues.get(propertyName);
if (val == null) {
propertySheetModel.setValue(name, "");
} else {
View view = this.getChild(name);
if (view instanceof CCCheckBox) {
String trueValue = ServerPropertyValidator.getTrueValue(propertyName);
String v = (val.equals(trueValue)) ? "true" : "false";
propertySheetModel.setValue(name, v);
} else if (view instanceof CCEditableList) {
CCEditableList list = (CCEditableList) view;
list.resetStateData();
// The list is stored as a comma delimited String
list.getModel().setOptionList(CollectionUtils.asSet(val.split(",")));
propertySheetModel.setValue(name, val);
} else {
propertySheetModel.setValue(name, XMLUtils.escapeSpecialCharacters(val));
}
}
}
}
}
use of com.sun.web.ui.view.editablelist.CCEditableList in project OpenAM by OpenRock.
the class SiteEditViewBean method handleButton1Request.
/**
* Handles create site request.
*
* @param event Request invocation event
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
submitCycle = true;
String siteName = (String) getPageSessionAttribute(PG_ATTR_SITE_NAME);
String primaryURL = (String) getDisplayFieldValue(TF_URL);
CCEditableList elist = (CCEditableList) getChild(EDITABLE_FAILOVER_URLS);
elist.restoreStateData();
Set failoverURLs = getValues(elist.getModel().getOptionList());
ServerSiteModel model = (ServerSiteModel) getModel();
try {
model.modifySite(siteName, primaryURL, failoverURLs);
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "siteconfig.updated");
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
forwardTo();
}
use of com.sun.web.ui.view.editablelist.CCEditableList in project OpenAM by OpenRock.
the class SiteEditViewBean method getFailoverURLs.
private void getFailoverURLs(String siteName, ServerSiteModel model) throws AMConsoleException {
if (!submitCycle) {
Set failoverURLs = model.getSiteFailoverURLs(siteName);
CCEditableList elist = (CCEditableList) getChild(EDITABLE_FAILOVER_URLS);
CCEditableListModel m = (CCEditableListModel) elist.getModel();
elist.resetStateData();
m.setOptionList(failoverURLs);
}
}
Aggregations