KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > core > www > IdListTag


1 /*
2  * Copyright (c) 2003 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: IdListTag.java,v 1.6 2007/01/07 06:14:09 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21  
22 package org.opensubsystems.core.www;
23
24 import java.util.Collection JavaDoc;
25
26 import javax.servlet.jsp.JspException JavaDoc;
27 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
28
29 import org.opensubsystems.core.util.DataObjectUtils;
30
31 /**
32  * Custom tag to construct string of ids of collection of data objects presented
33  * in a request separated by ','.
34  *
35  * @version $Id: IdListTag.java,v 1.6 2007/01/07 06:14:09 bastafidli Exp $
36  * @author Julo Legeny
37  * @code.reviewer Miro Halas
38  * @code.reviewed 1.3 2006/02/17 06:54:09 bastafidli
39  */

40 public class IdListTag extends TagSupport JavaDoc
41 {
42    // Attributes ///////////////////////////////////////////////////////////////
43

44    /**
45     * Generated serial version id for this class.
46     */

47    private static final long serialVersionUID = 6752629609523601805L;
48
49    /**
50     * Name of the request attribute contaning collection of data objects whose
51     * list of ids should be constructed. Required.
52     */

53    protected String JavaDoc m_strName;
54    
55    // Constructor //////////////////////////////////////////////////////////////
56

57    /**
58     * Constructor for custom tag.
59     */

60    public IdListTag()
61    {
62       super();
63
64       m_strName = "";
65    }
66    
67    // Business logic ///////////////////////////////////////////////////////////
68

69    /**
70     * {@inheritDoc}
71     */

72    public int doStartTag(
73    ) throws JspException JavaDoc
74    {
75       Collection JavaDoc colItems;
76       
77       colItems = (Collection JavaDoc)pageContext.getRequest().getAttribute(m_strName);
78       if ((colItems != null) && (!colItems.isEmpty()))
79       {
80          TagUtils.write(pageContext,
81                         DataObjectUtils.parseCollectionIdsToString(colItems, ","));
82       }
83       return (SKIP_BODY);
84    }
85
86    /**
87     * {@inheritDoc}
88     */

89    public int doEndTag(
90    ) throws JspException JavaDoc
91    {
92       return (EVAL_PAGE);
93    }
94
95    /**
96     * Returns the name
97     *
98     * @return name
99     */

100    public String JavaDoc getName()
101    {
102       return m_strName;
103    }
104
105    /**
106     * Sets the name
107     *
108     * @param strName - name that will be set
109     */

110    public void setName(
111       String JavaDoc strName
112    )
113    {
114       m_strName = strName;
115    }
116 }
117
Popular Tags