001    /**
002     * Copyright (c) 2000-2012 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.taglib.ui;
016    
017    import com.liferay.portal.kernel.dao.search.ResultRow;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    
020    import javax.servlet.jsp.JspException;
021    import javax.servlet.jsp.JspTagException;
022    import javax.servlet.jsp.tagext.TagSupport;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class SearchContainerRowParameterTag<R> extends TagSupport {
028    
029            @Override
030            public int doStartTag() throws JspException {
031                    SearchContainerRowTag<R> searchContainerRowTag =
032                            (SearchContainerRowTag<R>)findAncestorWithClass(
033                                    this, SearchContainerRowTag.class);
034    
035                    if (searchContainerRowTag == null) {
036                            throw new JspTagException(
037                                    "Requires liferay-ui:search-container-row");
038                    }
039    
040                    ResultRow resultRow = searchContainerRowTag.getRow();
041    
042                    if (_name.equals("className")) {
043                            resultRow.setClassName(_name);
044                    }
045                    else if (_name.equals("classHoverName")) {
046                            resultRow.setClassHoverName((String)_value);
047                    }
048                    else if (_name.equals("restricted")) {
049                            resultRow.setRestricted(
050                                    GetterUtil.getBoolean((String)_value, false));
051                    }
052                    else {
053                            resultRow.setParameter(_name, _value);
054                    }
055    
056                    return EVAL_BODY_INCLUDE;
057            }
058    
059            public void setName(String name) {
060                    _name = name;
061            }
062    
063            public void setValue(Object value) {
064                    _value = value;
065            }
066    
067            private String _name;
068            private Object _value;
069    
070    }