001    /**
002     * Copyright (c) 2000-2010 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 extends TagSupport {
028    
029            public int doStartTag() throws JspException {
030                    SearchContainerRowTag parentRowTag =
031                            (SearchContainerRowTag)findAncestorWithClass(
032                            this, SearchContainerRowTag.class);
033    
034                    if (parentRowTag == null) {
035                            throw new JspTagException(
036                                    "Requires liferay-ui:search-container-row");
037                    }
038    
039                    ResultRow row = parentRowTag.getRow();
040    
041                    if (_name.equals("className")) {
042                            row.setClassName(_name);
043                    }
044                    else if (_name.equals("classHoverName")) {
045                            row.setClassHoverName((String)_value);
046                    }
047                    else if (_name.equals("restricted")) {
048                            row.setRestricted(GetterUtil.getBoolean((String)_value, false));
049                    }
050                    else {
051                            row.setParameter(_name, _value);
052                    }
053    
054                    return EVAL_BODY_INCLUDE;
055            }
056    
057            public void setName(String name) {
058                    _name = name;
059            }
060    
061            public void setValue(Object value) {
062                    _value = value;
063            }
064    
065            private String _name;
066            private Object _value;
067    
068    }