001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.jsp.util;
029
030import org.opencms.file.CmsObject;
031import org.opencms.file.CmsResource;
032
033import java.util.List;
034
035/**
036 * Allows JSP access to the results of a &lt;cms:resourceload ... &gt; operation using the JSTL and EL.<p>
037 *
038 * @since 8.0
039 *
040 * @see org.opencms.jsp.CmsJspTagResourceLoad
041 * @see CmsJspResourceAccessBean
042 */
043public class CmsJspResourceLoadBean {
044
045    /** The OpenCms context of the current user. */
046    protected CmsObject m_cms;
047
048    /** The list of results of the resource loader. */
049    protected List<CmsResource> m_resources;
050
051    /**
052     * No argument constructor, required for a JavaBean.<p>
053     *
054     * You must call {@link #init(CmsObject, List)} and provide the
055     * required values when you use this constructor.<p>
056     *
057     * @see #init(CmsObject, List)
058     */
059    public CmsJspResourceLoadBean() {
060
061        // must call init() manually later
062    }
063
064    /**
065     * Creates a new context bean using the OpenCms context of the current user.<p>
066     *
067     * The current request context locale is used.<p>
068     *
069     * @param cms the OpenCms context of the current user
070     * @param resources the resources to access, must contain objects of type {@link CmsResource}
071     */
072    public CmsJspResourceLoadBean(CmsObject cms, List<CmsResource> resources) {
073
074        init(cms, resources);
075    }
076
077    /**
078     * Returns the OpenCms user context this bean was initialized with.<p>
079     *
080     * @return the OpenCms user context this bean was initialized with
081     */
082    public CmsObject getCmsObject() {
083
084        return m_cms;
085    }
086
087    /**
088     * Returns a list of {@link CmsResource} instances.<p>
089     *
090     * @return a list of {@link CmsResource} instances
091     */
092    public List<CmsResource> getResources() {
093
094        return m_resources;
095    }
096
097    /**
098     * Initialize this instance.<p>
099     *
100     * @param cms the OpenCms context of the current user
101     * @param resources the resources to access, must contain objects of type {@link CmsResource}
102     */
103    public void init(CmsObject cms, List<CmsResource> resources) {
104
105        m_cms = cms;
106        m_resources = resources;
107    }
108}