Search in sources :

Example 11 with CCSelect

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());
    }
}
Also used : Set(java.util.Set) CCSelect(com.sun.web.ui.view.html.CCSelect) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 12 with CCSelect

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());
    }
}
Also used : Set(java.util.Set) CCSelect(com.sun.web.ui.view.html.CCSelect) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 13 with CCSelect

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;
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CCSelect(com.sun.web.ui.view.html.CCSelect) HashMap(java.util.HashMap) Map(java.util.Map)

Example 14 with CCSelect

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());
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) CCSelect(com.sun.web.ui.view.html.CCSelect) OptionList(com.iplanet.jato.view.html.OptionList)

Example 15 with CCSelect

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());
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) CCSelect(com.sun.web.ui.view.html.CCSelect) OptionList(com.iplanet.jato.view.html.OptionList) HashSet(java.util.HashSet)

Aggregations

CCSelect (com.sun.web.ui.view.html.CCSelect)16 Set (java.util.Set)15 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)7 OptionList (com.iplanet.jato.view.html.OptionList)5 HashSet (java.util.HashSet)5 AMModel (com.sun.identity.console.base.model.AMModel)2 Iterator (java.util.Iterator)2 Option (com.iplanet.jato.view.html.Option)1 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)1 SelectRealmModel (com.sun.identity.console.policy.model.SelectRealmModel)1 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)1 CCStaticTextField (com.sun.web.ui.view.html.CCStaticTextField)1 CCTextField (com.sun.web.ui.view.html.CCTextField)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 TreeSet (java.util.TreeSet)1