001
014
015 package com.liferay.taglib.aui;
016
017 import com.liferay.portal.kernel.bean.BeanPropertiesUtil;
018 import com.liferay.portal.kernel.util.ParamUtil;
019 import com.liferay.portal.kernel.util.StringPool;
020 import com.liferay.portal.kernel.util.TextFormatter;
021 import com.liferay.portal.kernel.util.Validator;
022 import com.liferay.taglib.aui.base.BaseSelectTag;
023
024 import javax.servlet.http.HttpServletRequest;
025
026
031 public class SelectTag extends BaseSelectTag {
032
033 @Override
034 protected boolean isCleanUpSetAttributes() {
035 return _CLEAN_UP_SET_ATTRIBUTES;
036 }
037
038 @Override
039 protected void setAttributes(HttpServletRequest request) {
040 super.setAttributes(request);
041
042 Object bean = getBean();
043
044 if (bean == null) {
045 bean = pageContext.getAttribute("aui:model-context:bean");
046 }
047
048 String name = getName();
049
050 int pos = name.indexOf(StringPool.DOUBLE_DASH);
051
052 if (pos != -1) {
053 name = name.substring(pos + 2, name.length() - 2);
054 }
055
056 String id = getId();
057
058 if (Validator.isNull(id)) {
059 id = name;
060 }
061
062 String label = getLabel();
063
064 if (label == null) {
065 label = TextFormatter.format(name, TextFormatter.K);
066 }
067
068 String listType = getListType();
069 String listTypeFieldName = getListTypeFieldName();
070
071 if (Validator.isNotNull(listType) &&
072 Validator.isNull(listTypeFieldName)) {
073
074 listTypeFieldName = "typeId";
075 }
076
077 String value = StringPool.BLANK;
078
079 if (Validator.isNull(listType)) {
080 if (bean != null) {
081 value = BeanPropertiesUtil.getStringSilent(bean, name, value);
082 }
083
084 if (!getIgnoreRequestValue()) {
085 value = ParamUtil.getString(request, name, value);
086 }
087 }
088
089 setNamespacedAttribute(request, "bean", bean);
090 setNamespacedAttribute(request, "id", id);
091 setNamespacedAttribute(request, "label", label);
092 setNamespacedAttribute(request, "listTypeFieldName", listTypeFieldName);
093 setNamespacedAttribute(request, "value", value);
094 }
095
096 private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
097
098 }