use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.
the class AMPropertySheet method setAttributeValues.
/**
* Set values to model of a <code>CCPropertySheet</code> component.
*
* @param attributeValues Map of attribute name to values.
*/
public void setAttributeValues(Map attributeValues, AMModel amModel) {
AMPropertySheetModel model = (AMPropertySheetModel) getModel();
ViewBean parent = getParentViewBean();
for (Iterator iter = attributeValues.keySet().iterator(); iter.hasNext(); ) {
String name = (String) iter.next();
// different attribute types set different types of data
// get Object from the values and convert as needed.
Object values = attributeValues.get(name);
View view = null;
try {
view = parent.getChild(name);
} catch (IllegalArgumentException e) {
// skip this attribute. its not defined in the property sheet
continue;
}
if (view != null) {
if (setValuesToMultipleChoices(parent, name, values, amModel, model) || setValuesToAddRemove(view, name, values, amModel, model) || setValuesToEditableList(view, name, values, amModel, model) || setValuesToOrderedList(view, name, values, amModel, model) || setValuesToUnOrderedList(view, name, values, amModel, model) || setValuesToMapList(view, name, values, amModel, model) || setValuesToDateTime(view, name, values, amModel, model) || setValuesToSelect(view, name, values, amModel, model)) {
// do nothing.
} else {
// all other element types should be passing a set
if (Set.class.isInstance(values)) {
if (model.isChildSupported(name + PropertyTemplate.PWD_CONFIRM_SUFFIX)) {
model.setValues(name + PropertyTemplate.PWD_CONFIRM_SUFFIX, ((Set) values).toArray(), amModel);
}
if ((values != null) && !((Set) values).isEmpty() && model.isChildSupported(name + PropertyTemplate.PASSWORD_VALUE_TAG)) {
model.setValue(name, PASSWORD_MASK);
} else {
model.setValues(name, ((Set) values).toArray(), amModel);
}
}
}
}
}
}
use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.
the class AMPropertySheet method init.
public void init() {
ViewBean parent = getParentViewBean();
AMPropertySheetModel model = (AMPropertySheetModel) getModel();
Map radioComponents = model.getRadioDefaultValues();
if ((radioComponents != null) && !radioComponents.isEmpty()) {
for (Iterator i = radioComponents.keySet().iterator(); i.hasNext(); ) {
String name = (String) i.next();
CCRadioButton rb = (CCRadioButton) parent.getChild(name);
Object value = rb.getValue();
if (value == null) {
rb.setValue(radioComponents.get(name));
}
}
}
}
use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.
the class AMServiceProfileViewBeanBase method createPropertyModel.
protected void createPropertyModel() {
AMServiceProfileModel model = (AMServiceProfileModel) getModel();
if (model != null) {
try {
propertySheetModel = new AMPropertySheetModel(getPropertySheetXML(model));
propertySheetModel.clear();
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
}
}
use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.
the class AMPropertySheet method getAttributeValues.
/**
* Returns a map of attribute name to values.
*
* @param attrNames Set of attribute names to retrieve.
* @return map of attribute name to values.
* @throws ModelControlException if cannot get model of property sheet.
* @throws AMConsoleException if password and confirm password values do
* not match.
*/
public Map getAttributeValues(Collection attrNames) throws ModelControlException, AMConsoleException {
restoreStateData(attrNames);
AMPropertySheetModel model = (AMPropertySheetModel) getModel();
Map attrValues = new HashMap(attrNames.size() * 2);
Map multipleChoiceValues = getMultipleChoiceValues(model);
for (Iterator iter = attrNames.iterator(); iter.hasNext(); ) {
String name = (String) iter.next();
Object childModel = model.getModel(name);
Set values = null;
if (CCAddRemoveModel.class.isInstance(childModel)) {
values = getValues(((CCAddRemoveModel) childModel).getSelectedOptionList());
} else if (CCUnOrderedListModel.class.isInstance(childModel)) {
values = getListValues(((CCUnOrderedListModel) childModel).getOptionList());
if ((values == null) || values.isEmpty()) {
values = new HashSet(2);
values.add("[0]=");
}
} else if (CCMapListModel.class.isInstance(childModel)) {
values = getValues(((CCMapListModel) childModel).getOptionList());
if ((values == null) || values.isEmpty()) {
values = new HashSet(2);
values.add("[]=");
}
} else if (CCEditableListModel.class.isInstance(childModel)) {
values = getValues(((CCEditableListModel) childModel).getOptionList());
} else if (CCOrderedListModel.class.isInstance(childModel)) {
values = getListValues(((CCOrderedListModel) childModel).getSelectedOptionList());
if ((values == null) || values.isEmpty()) {
values = new HashSet(2);
values.add("[0]=");
}
} else if (model.isChildSupported(name + PropertyTemplate.PWD_CONFIRM_SUFFIX)) {
String pwd = (String) model.getValue(name);
String confirmPwd = (String) model.getValue(name + PropertyTemplate.PWD_CONFIRM_SUFFIX);
if (pwd.equals(confirmPwd)) {
if (!pwd.equals(AMPropertySheetModel.passwordRandom)) {
values = new HashSet(2);
values.add(pwd);
}
} else {
throw new AMConsoleException("password-mismatched");
}
} else {
values = (Set) multipleChoiceValues.get(name);
if (values == null) {
values = AMAdminUtils.toSetIgnoreEmpty(model.getValues(name));
}
}
if (values != null) {
attrValues.put(name, values);
}
}
return attrValues;
}
use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.
the class ServicesSelectViewBean method createPropertyModel.
private void createPropertyModel() {
propertySheetModel = new AMPropertySheetModel(getClass().getClassLoader().getResourceAsStream("com/sun/identity/console/propertyEntityServicesSelect.xml"));
propertySheetModel.clear();
}
Aggregations