001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.dao.search;
016    
017    import com.liferay.portal.kernel.language.LanguageUtil;
018    import com.liferay.portal.kernel.util.HtmlUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.kernel.util.Validator;
022    
023    import javax.portlet.PortletResponse;
024    
025    import javax.servlet.http.HttpServletRequest;
026    
027    /**
028     * @author Eudaldo Alonso
029     */
030    public class EmptyOnClickRowChecker extends RowChecker {
031    
032            public EmptyOnClickRowChecker(PortletResponse portletResponse) {
033                    super(portletResponse);
034            }
035    
036            @Override
037            protected String getOnClick(
038                    String checkBoxRowIds, String checkBoxAllRowIds,
039                    String checkBoxPostOnClick) {
040    
041                    return StringPool.BLANK;
042            }
043    
044            @Override
045            protected String getRowCheckBox(
046                    HttpServletRequest request, boolean checked, boolean disabled,
047                    String name, String value, String checkBoxRowIds,
048                    String checkBoxAllRowIds, String checkBoxPostOnClick) {
049    
050                    StringBundler sb = new StringBundler(15);
051    
052                    sb.append("<input ");
053    
054                    if (checked) {
055                            sb.append("checked ");
056                    }
057    
058                    sb.append("class=\"");
059                    sb.append(getCssClass());
060                    sb.append("\" ");
061    
062                    if (disabled) {
063                            sb.append("disabled ");
064                    }
065    
066                    sb.append("name=\"");
067                    sb.append(name);
068                    sb.append("\" title=\"");
069                    sb.append(LanguageUtil.get(request.getLocale(), "select"));
070                    sb.append("\" type=\"checkbox\" value=\"");
071                    sb.append(HtmlUtil.escapeAttribute(value));
072                    sb.append("\" ");
073    
074                    if (Validator.isNotNull(getAllRowIds())) {
075                            sb.append(
076                                    getOnClick(
077                                            checkBoxRowIds, checkBoxAllRowIds, checkBoxPostOnClick));
078                    }
079    
080                    sb.append(">");
081    
082                    return sb.toString();
083            }
084    
085    }