001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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 row = searchContainerRowTag.getRow();
041    
042                    if (_name.equals("className")) {
043                            row.setClassName(_name);
044                    }
045                    else if (_name.equals("classHoverName")) {
046                            row.setClassHoverName((String)_value);
047                    }
048                    else if (_name.equals("restricted")) {
049                            row.setRestricted(GetterUtil.getBoolean((String)_value, false));
050                    }
051                    else {
052                            row.setParameter(_name, _value);
053                    }
054    
055                    return EVAL_BODY_INCLUDE;
056            }
057    
058            public void setName(String name) {
059                    _name = name;
060            }
061    
062            public void setValue(Object value) {
063                    _value = value;
064            }
065    
066            private String _name;
067            private Object _value;
068    
069    }