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