001
014
015 package com.liferay.taglib.ui;
016
017 import com.liferay.portal.kernel.dao.search.DisplayTerms;
018 import com.liferay.portal.kernel.language.LanguageUtil;
019 import com.liferay.portal.kernel.util.Validator;
020 import com.liferay.taglib.BaseValidatorTagSupport;
021 import com.liferay.taglib.util.TagResourceBundleUtil;
022
023 import java.util.ResourceBundle;
024
025 import javax.servlet.http.HttpServletRequest;
026
027
030 public class InputSearchTag extends BaseValidatorTagSupport {
031
032 @Override
033 public String getInputName() {
034 return _name;
035 }
036
037 public void setAutoFocus(boolean autoFocus) {
038 _autoFocus = autoFocus;
039 }
040
041 public void setButtonLabel(String buttonLabel) {
042 _buttonLabel = buttonLabel;
043 }
044
045 public void setCssClass(String cssClass) {
046 _cssClass = cssClass;
047 }
048
049 public void setId(String id) {
050 _id = id;
051 }
052
053 public void setMarkupView(String markupView) {
054 _markupView = markupView;
055 }
056
057 public void setName(String name) {
058 _name = name;
059 }
060
061 public void setPlaceholder(String placeholder) {
062 _placeholder = placeholder;
063 }
064
065 public void setShowButton(boolean showButton) {
066 _showButton = showButton;
067 }
068
069 public void setTitle(String title) {
070 _title = title;
071 }
072
073 public void setUseNamespace(boolean useNamespace) {
074 _useNamespace = useNamespace;
075 }
076
077 @Override
078 protected void cleanUp() {
079 super.cleanUp();
080
081 _autoFocus = false;
082 _buttonLabel = null;
083 _cssClass = null;
084 _id = null;
085 _markupView = null;
086 _name = null;
087 _placeholder = null;
088 _showButton = true;
089 _title = null;
090 _useNamespace = true;
091 }
092
093 @Override
094 protected String getPage() {
095 if (Validator.isNotNull(_markupView)) {
096 return "/html/taglib/ui/input_search/" + _markupView +"/page.jsp";
097 }
098
099 return "/html/taglib/ui/input_search/page.jsp";
100 }
101
102 @Override
103 protected void setAttributes(HttpServletRequest request) {
104 String buttonLabel = _buttonLabel;
105
106 ResourceBundle resourceBundle = TagResourceBundleUtil.getResourceBundle(
107 pageContext);
108
109 if (Validator.isNull(buttonLabel)) {
110 buttonLabel = LanguageUtil.get(resourceBundle, "search");
111 }
112
113 String cssClass = _cssClass;
114
115 if (Validator.isNull(_name)) {
116 _name = DisplayTerms.KEYWORDS;
117 }
118
119 String id = _id;
120
121 if (Validator.isNull(id)) {
122 id = _name;
123 }
124
125 String placeholder = _placeholder;
126
127 if (Validator.isNull(placeholder)) {
128 placeholder = buttonLabel;
129 }
130
131 String title = _title;
132
133 if (title == null) {
134 title = LanguageUtil.get(resourceBundle, "search");
135 }
136
137 request.setAttribute(
138 "liferay-ui:input-search:autoFocus", String.valueOf(_autoFocus));
139 request.setAttribute(
140 "liferay-ui:input-search:buttonLabel", buttonLabel);
141 request.setAttribute("liferay-ui:input-search:cssClass", cssClass);
142 request.setAttribute("liferay-ui:input-search:id", id);
143 request.setAttribute("liferay-ui:input-search:name", _name);
144 request.setAttribute(
145 "liferay-ui:input-search:placeholder", placeholder);
146 request.setAttribute("liferay-ui:input-search:showButton", _showButton);
147 request.setAttribute("liferay-ui:input-search:title", title);
148 request.setAttribute(
149 "liferay-ui:input-search:useNamespace", _useNamespace);
150 }
151
152 private boolean _autoFocus;
153 private String _buttonLabel;
154 private String _cssClass;
155 private String _id;
156 private String _markupView;
157 private String _name;
158 private String _placeholder;
159 private boolean _showButton = true;
160 private String _title;
161 private boolean _useNamespace = true;
162
163 }