use of com.sun.web.ui.view.html.CCSelect in project OpenAM by OpenRock.
the class PMDefaultAuthLevelConditionAddViewBean method beginDisplay.
public void beginDisplay(DisplayEvent event) throws ModelControlException {
super.beginDisplay(event);
String filter = (String) getDisplayFieldValue(AuthLevelHelper.ATTR_FILTER);
if ((filter == null) || (filter.trim().length() == 0)) {
setDisplayFieldValue(AuthLevelHelper.ATTR_FILTER, "*");
}
try {
Set realmNames = helper.getRealmNames(filter, (PolicyModel) getModel());
if (realmNames.isEmpty()) {
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.condition.authlevel.no.search.result.message");
} else {
realmNames.add("");
}
CCSelect sl = (CCSelect) getChild(AuthLevelHelper.ATTR_REALM);
sl.setOptions(createOptionList(getLabelValueMap(realmNames)));
if (sl.getValue() == null) {
sl.setValue(realmNames.iterator().next());
}
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
}
use of com.sun.web.ui.view.html.CCSelect in project OpenAM by OpenRock.
the class PMDefaultAuthLevelConditionEditViewBean method beginDisplay.
/**
* Searches for realms and set up realm selectable list.
*
* @param event Display Event.
* @throws ModelControlException if <code>JATO</code> default model fails.
*/
public void beginDisplay(DisplayEvent event) throws ModelControlException {
super.beginDisplay(event);
String filter = (String) getDisplayFieldValue(AuthLevelHelper.ATTR_FILTER);
if ((filter == null) || (filter.trim().length() == 0)) {
setDisplayFieldValue(AuthLevelHelper.ATTR_FILTER, "*");
}
PolicyModel model = (PolicyModel) getModel();
try {
Set realmNames = helper.getRealmNames(filter, model);
if (realmNames.isEmpty()) {
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.condition.authlevel.no.search.result.message");
} else {
realmNames.add("");
}
String realmValue = (String) propertySheetModel.getValue(AuthLevelHelper.ATTR_REALM);
if (realmValue == null) {
realmValue = "";
}
if (!bSearchForRealm) {
if ((realmValue.length() > 0) && !realmNames.contains(realmValue)) {
realmNames.add(realmValue);
if (!isInlineAlertMessageSet()) {
String msg = model.getLocalizedString("policy.condition.authlevel.no.longer.exist.realm");
String[] param = { realmValue };
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", MessageFormat.format(msg, (Object[]) param));
}
}
}
CCSelect sl = (CCSelect) getChild(AuthLevelHelper.ATTR_REALM);
sl.setOptions(createOptionList(getLabelValueMap(realmNames)));
if (sl.getValue() == null) {
sl.setValue(realmValue);
}
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
}
use of com.sun.web.ui.view.html.CCSelect in project OpenAM by OpenRock.
the class AMPropertySheet method setValuesToSelect.
private boolean setValuesToSelect(View view, String name, Object values, AMModel amModel, AMPropertySheetModel model) {
boolean set = false;
if (CCSelect.class.isInstance(view)) {
((CCSelect) view).resetStateData();
// values and the selected values.
if (Map.class.isInstance(values)) {
Map tmp = (Map) values;
Set choices = (Set) tmp.get(AMAdminConstants.CHOICES);
values = (Set) tmp.get(AMAdminConstants.VALUES);
CCSelect sl = (CCSelect) view;
sl.setOptions(AMViewBeanBase.createOptionList(choices, amModel.getUserLocale()));
model.setValues(name, ((Set) values).toArray(), amModel);
} else {
model.setValues(name, ((Set) values).toArray(), amModel);
}
set = true;
}
return set;
}
use of com.sun.web.ui.view.html.CCSelect in project OpenAM by OpenRock.
the class SelectRealmViewBean method beginDisplay.
public void beginDisplay(DisplayEvent event) throws ModelControlException {
super.beginDisplay(event);
disableButton("button1", true);
setDisplayFieldValue(TXT_EMPTY_REALM, getModel().getLocalizedString("policy.condition.null.realm"));
String filter = (String) getDisplayFieldValue(ATTR_FILTER);
if ((filter == null) || (filter.trim().length() == 0)) {
setDisplayFieldValue(AuthToRealmHelper.ATTR_FILTER, "*");
filter = "*";
}
Set realmNames = getRealmNames(filter);
if ((realmNames != null) && !realmNames.isEmpty()) {
CCSelect sl = (CCSelect) getChild(ATTR_REALM_NAMES);
sl.setOptions(createOptionList(getLabelValueMap(realmNames)));
String realm = null;
if (!bRealmSelect) {
realm = "";
sl.setValue(realm);
} else {
realm = (String) sl.getValue();
}
setSchemes(realm);
} else {
CCSelect sl = (CCSelect) getChild(ATTR_SCHEMES);
sl.setOptions(new OptionList());
}
}
use of com.sun.web.ui.view.html.CCSelect in project OpenAM by OpenRock.
the class AuthToServiceEditViewBean method beginDisplay.
/**
* Set the realm names and service names.
*
* @param event Display event.
* @throws ModelControlException if default <code>JATO</code> cannot be
* instantiated.
*/
public void beginDisplay(DisplayEvent event) throws ModelControlException {
super.beginDisplay(event);
String filter = (String) getDisplayFieldValue(AuthToServiceHelper.ATTR_FILTER);
if ((filter == null) || (filter.trim().length() == 0)) {
setDisplayFieldValue(AuthToServiceHelper.ATTR_FILTER, "*");
}
Set realmNames = getRealmNames(filter);
if (realmNames != null) {
realmNames.add("");
}
boolean nolongExistRealm = false;
String realmValue = (String) propertySheetModel.getValue(AuthToServiceHelper.ATTR_REALM);
if (!bSearchForRealm && !bRealmSelect) {
if (realmValue == null) {
realmValue = "";
}
if (realmNames == null) {
realmNames = new HashSet(2);
}
if (!realmNames.contains(realmValue)) {
realmNames.add(realmValue);
nolongExistRealm = true;
if (!isInlineAlertMessageSet()) {
String msg = getModel().getLocalizedString("policy.condition.authlevel.no.longer.exist.realm");
String[] param = { realmValue };
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", MessageFormat.format(msg, (Object[]) param));
}
}
}
if ((realmNames != null) && !realmNames.isEmpty()) {
CCSelect sl = (CCSelect) getChild(AuthToServiceHelper.ATTR_REALM);
sl.setOptions(createOptionList(getLabelValueMap(realmNames)));
String realm = (bSearchForRealm) ? (String) realmNames.iterator().next() : (String) sl.getValue();
if (realm == null) {
realm = realmValue;
sl.setValue(realm);
}
if (!nolongExistRealm) {
setServiceNames(realm);
} else {
CCSelect slService = (CCSelect) getChild(AuthToServiceHelper.ATTR_SERVICE);
Set svcName = new HashSet(2);
svcName.add(propertySheetModel.getValue(AuthToServiceHelper.ATTR_SERVICE));
slService.setOptions(createOptionList(svcName));
}
} else {
CCSelect slService = (CCSelect) getChild(AuthToServiceHelper.ATTR_SERVICE);
slService.setOptions(new OptionList());
}
}
Aggregations