1
22
23 package com.liferay.portal.kernel.dao.search;
24
25 import com.liferay.portal.kernel.util.StringMaker;
26 import com.liferay.portal.kernel.util.StringPool;
27 import com.liferay.portal.kernel.util.Validator;
28
29 import javax.portlet.RenderResponse;
30
31
37 public class RowChecker {
38
39 public static final String ALIGN = "left";
40
41 public static final String VALIGN = "middle";
42
43 public static final int COLSPAN = 1;
44
45 public static final String FORM_NAME = "fm";
46
47 public static final String ALL_ROW_IDS = "allRowIds";
48
49 public static final String ROW_IDS = "rowIds";
50
51 public RowChecker(RenderResponse res) {
52 this(res, ALIGN, VALIGN, COLSPAN, FORM_NAME, ALL_ROW_IDS, ROW_IDS);
53 }
54
55 public RowChecker(
56 RenderResponse res, String align, String valign, String formName,
57 String allRowsId, String rowId) {
58
59 this(res, align, valign, COLSPAN, formName, allRowsId, rowId);
60 }
61
62 public RowChecker(
63 RenderResponse res, String align, String valign, int colspan,
64 String formName, String allRowsId, String rowId) {
65
66 _align = align;
67 _valign = valign;
68 _colspan = colspan;
69 _formName = res.getNamespace() + formName;
70
71 if (Validator.isNotNull(allRowsId)) {
72 _allRowsId = res.getNamespace() + allRowsId;
73 }
74
75 _rowId = res.getNamespace() + rowId;
76 }
77
78 public String getAlign() {
79 return _align;
80 }
81
82 public String getValign() {
83 return _valign;
84 }
85
86 public int getColspan() {
87 return _colspan;
88 }
89
90 public String getFormName() {
91 return _formName;
92 }
93
94 public String getAllRowsId() {
95 return _allRowsId;
96 }
97
98 public String getRowId() {
99 return _rowId;
100 }
101
102 public String getAllRowsCheckBox() {
103 if (Validator.isNull(_allRowsId)) {
104 return StringPool.BLANK;
105 }
106 else {
107 StringMaker sm = new StringMaker();
108
109 sm.append("<input name=\"");
110 sm.append(_allRowsId);
111 sm.append("\" type=\"checkbox\" ");
112 sm.append("onClick=\"Liferay.Util.checkAll(");
113 sm.append(_formName);
114 sm.append(", '");
115 sm.append(_rowId);
116 sm.append("', this");
117 sm.append(");\">");
118
119 return sm.toString();
120 }
121 }
122
123 public String getRowCheckBox(boolean checked, String primaryKey) {
124 StringMaker sm = new StringMaker();
125
126 sm.append("<input ");
127
128 if (checked) {
129 sm.append("checked ");
130 }
131
132 sm.append("name=\"");
133 sm.append(_rowId);
134 sm.append("\" type=\"checkbox\" value=\"");
135 sm.append(primaryKey);
136 sm.append("\" ");
137
138 if (Validator.isNotNull(_allRowsId)) {
139 sm.append("onClick=\"Liferay.Util.checkAllBox(");
140 sm.append(_formName);
141 sm.append(", '");
142 sm.append(_rowId);
143 sm.append("', ");
144 sm.append(_allRowsId);
145 sm.append(");\"");
146 }
147
148 sm.append(">");
149
150 return sm.toString();
151 }
152
153 public boolean isChecked(Object obj) {
154 return false;
155 }
156
157 private String _align;
158 private String _valign;
159 private int _colspan;
160 private String _formName;
161 private String _allRowsId;
162 private String _rowId;
163
164 }