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