use of com.sun.identity.sm.AttributeSchema.UIType in project OpenAM by OpenRock.
the class PropertyXMLBuilderBase method buildAttributeSchemaTypeXML.
protected void buildAttributeSchemaTypeXML(AttributeSchema as, StringBuffer xml, AMModel model, ResourceBundle serviceBundle, boolean addSubSection) {
String tagClassName = getTagClassName(as);
if (tagClassName != null) {
String name = getAttributeNameForPropertyXML(as);
boolean editableList = tagClassName.equals(TAGNAME_EDITABLE_LIST);
boolean orderedList = tagClassName.equals(TAGNAME_ORDERED_LIST);
boolean unorderedList = tagClassName.equals(TAGNAME_UNORDERED_LIST);
boolean mapList = tagClassName.equals(TAGNAME_MAP_LIST);
boolean globalMapList = tagClassName.equals(TAGNAME_GLOBAL_MAP_LIST);
AttributeSchema.Type type = as.getType();
AttributeSchema.UIType uitype = as.getUIType();
boolean addremovelist = type.equals(AttributeSchema.Type.MULTIPLE_CHOICE) && (uitype != null) && uitype.equals(AttributeSchema.UIType.ADDREMOVELIST);
boolean listTyped = editableList || orderedList || unorderedList || mapList || globalMapList || addremovelist;
if (listTyped && addSubSection) {
/*
* create a subsection without a title to hold the
* editable list component.
*/
xml.append(SUBSECTION_DUMMY_START_TAG);
}
if (needRequiredTag(as)) {
xml.append(PROPERTY_REQUIRED_START_TAG);
} else {
xml.append(PROPERTY_START_TAG);
}
addLabel(as, xml, serviceBundle);
if (addremovelist) {
xml.append(GROUP_START_TAG).append(PROPERTY_START_TAG);
appendAddRemoveListComponent(as, xml, serviceBundle);
addremovelist = true;
} else {
//need to handle link specially.
if (tagClassName.equals(TAGNAME_BUTTON)) {
String editString = model.getLocalizedString("label.edit");
Object[] pLink = { "'" + name + "'", editString };
xml.append(MessageFormat.format(COMPONENT_BUTTON_START_TAG, pLink));
} else if (tagClassName.equals(TAGNAME_HREF)) {
String editString = model.getLocalizedString("label.edit");
Object[] pLink = { PropertyTemplate.PARAM_ATTR_NAME + "=" + name + "&" + PropertyTemplate.PARAM_PROPERTIES_VIEW_BEAN_URL + "=" + as.getPropertiesViewBeanURL(), "linkLabel" + name, editString };
xml.append(MessageFormat.format(COMPONENT_LINK_START_TAG, pLink));
} else if (tagClassName.equals(TAGNAME_CHECKBOX)) {
Object[] param = { name, tagClassName, model.getLocalizedString("label.Enable") };
xml.append(MessageFormat.format(COMPONENT_BOOLEAN_START_TAG, param));
} else if (listTyped) {
/*
* putting the editable list component wihin a group tag
* to help isolate the list box and text box together on the
* page. Otherwise the list component blends in with other
* components on the page.
*/
Object[] param = { name, model.getLocalizedString("label.current.value"), model.getLocalizedString("label.new.value") };
xml.append(GROUP_START_TAG).append(PROPERTY_START_TAG);
if (editableList) {
xml.append(MessageFormat.format(COMPONENT_EDITABLE_LIST_START_TAG, param));
} else if (orderedList) {
xml.append(MessageFormat.format(COMPONENT_ORDERED_LIST_START_TAG, param));
} else if (unorderedList) {
xml.append(MessageFormat.format(COMPONENT_UNORDERED_LIST_START_TAG, param));
} else if (mapList) {
xml.append(MessageFormat.format(COMPONENT_MAP_LIST_START_TAG, param));
appendChoiceValues(as, xml, model, serviceBundle);
} else if (globalMapList) {
xml.append(MessageFormat.format(COMPONENT_GLOBAL_MAP_LIST_START_TAG, param));
}
} else {
Object[] param = { name, tagClassName };
xml.append(MessageFormat.format(COMPONENT_START_TAG, param));
/*
* if its a textarea component add the no localize attribute
* set the size of the text field based on its syntax
*/
if (tagClassName.equals(TAGNAME_TEXTFIELD)) {
Object[] pSize = { getStringFieldSize(as) };
xml.append(MessageFormat.format(TEXTBOX_SIZE_TAG, pSize));
xml.append(NON_LOCALIZED_FIELD);
xml.append(NO_AUTO_SUBMIT);
} else if (tagClassName.equals(TAGNAME_TEXTAREA)) {
final Map<String, String> sizeMap = getTextAreaSize(as);
if (!sizeMap.isEmpty()) {
Object[] textAreaSize = { sizeMap.get("columns"), sizeMap.get("rows") };
xml.append(MessageFormat.format(TEXTAREA_SIZE_TAG, textAreaSize));
}
xml.append(NON_LOCALIZED_FIELD);
} else if (tagClassName.equals(TAGNAME_PASSWORD)) {
xml.append(NO_AUTO_SUBMIT);
}
appendChoiceValues(as, xml, model, serviceBundle);
}
xml.append(COMPONENT_END_TAG);
}
if (type.equals(AttributeSchema.Type.MULTIPLE_CHOICE)) {
if ((uitype == null) || !uitype.equals(AttributeSchema.UIType.ADDREMOVELIST)) {
appendMultipleChoiceCheckboxes(as, xml, serviceBundle);
}
}
appendDateMarker(as, xml);
getInlineHelp(as, xml, serviceBundle);
xml.append(PROPERTY_END_TAG);
// close off the group and subsection tags for the editable list
if (listTyped) {
xml.append(GROUP_END_TAG).append("<p>").append(PROPERTY_END_TAG);
if (addSubSection) {
xml.append(SUBSECTION_END_TAG);
}
}
}
}
use of com.sun.identity.sm.AttributeSchema.UIType in project OpenAM by OpenRock.
the class PropertyXMLBuilderBase method getTagClassName.
static String getTagClassName(AttributeSchema as) {
String tagClassName = null;
AttributeSchema.UIType uitype = as.getUIType();
if (uitype != null) {
String val = (String) mapUITypeToName.get(uitype);
try {
tagClassName = properties.getString(val);
} catch (MissingResourceException e) {
// do nothing
}
}
AttributeSchema.Type type = as.getType();
String valType = (String) mapTypeToName.get(type);
if ((tagClassName == null) && (valType != null)) {
try {
tagClassName = properties.getString(valType);
} catch (MissingResourceException e) {
// do nothing
}
}
if (tagClassName == null) {
AttributeSchema.Syntax syntax = as.getSyntax();
String valSyntax = (String) mapSyntaxToName.get(syntax);
if (valSyntax != null) {
try {
tagClassName = properties.getString(valType + "." + valSyntax);
} catch (MissingResourceException e) {
// do nothing
}
}
}
// last try
if (tagClassName == null) {
try {
tagClassName = properties.getString(valType + ".whatever");
} catch (MissingResourceException e) {
// do nothing
}
}
if ((tagClassName != null) && (tagClassName.trim().length() == 0)) {
tagClassName = null;
}
return tagClassName;
}
use of com.sun.identity.sm.AttributeSchema.UIType in project OpenAM by OpenRock.
the class PropertyXMLBuilderBase method appendChoiceValues.
private void appendChoiceValues(AttributeSchema as, StringBuffer xml, AMModel model, ResourceBundle serviceBundle) {
AttributeSchema.Type type = as.getType();
if (type.equals(AttributeSchema.Type.SINGLE)) {
AttributeSchema.UIType uitype = as.getUIType();
if ((uitype != null) && uitype.equals(AttributeSchema.UIType.RADIO)) {
Object[] p1 = { model.getLocalizedString("label.Yes"), "true" };
xml.append(MessageFormat.format(OPTION_TAG, p1));
Object[] p2 = { model.getLocalizedString("label.No"), "false" };
xml.append(MessageFormat.format(OPTION_TAG, p2));
}
} else if (type.equals(AttributeSchema.Type.SINGLE_CHOICE)) {
appendChoiceValueForSelectableComponent(as, xml, serviceBundle, true, OPTION_TAG);
} else if (type.equals(AttributeSchema.Type.LIST)) {
appendChoiceValueForSelectableComponent(as, xml, serviceBundle, false, VALUE_OPTION_TAG);
}
}
Aggregations