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; 029 030import java.util.Locale; 031 032import javax.servlet.http.HttpServletRequest; 033import javax.servlet.http.HttpServletResponse; 034import javax.servlet.jsp.JspException; 035import javax.servlet.jsp.PageContext; 036 037/** 038 * Provides access to XML content tag functions from scriptlet code.<p> 039 * 040 * Otherwise provides all functions from the parent class <code>{@link org.opencms.jsp.CmsJspActionElement}</code>.<p> 041 * 042 * @since 6.2.0 043 */ 044public class CmsJspXmlContentBean extends CmsJspActionElement { 045 046 /** 047 * Empty constructor, required for every JavaBean. 048 * 049 * @see CmsJspActionElement#CmsJspActionElement() 050 */ 051 public CmsJspXmlContentBean() { 052 053 super(); 054 } 055 056 /** 057 * Constructor, with parameters. 058 * 059 * @param context the JSP page context object 060 * @param req the JSP request 061 * @param res the JSP response 062 * 063 * @see CmsJspActionElement#CmsJspActionElement(PageContext, HttpServletRequest, HttpServletResponse) 064 */ 065 public CmsJspXmlContentBean(PageContext context, HttpServletRequest req, HttpServletResponse res) { 066 067 super(context, req, res); 068 } 069 070 /** 071 * Loads a set of <code>{@link org.opencms.xml.I_CmsXmlDocument}</code>, same as 072 * using the <code><cms:contentload collector="***" param="***" editable="***" /></code> tag.<p> 073 * 074 * The locale for accessing the content is read form the current OpenCms users request context.<p> 075 * 076 * @param collectorName the collector name to use 077 * @param collectorParam the parameters for the collector 078 * @param editable indicates if "direct edit" support is required (will insert additional HTML) 079 * 080 * @return an XML content container loaded with the selected content 081 * 082 * @throws JspException in case something goes wrong 083 */ 084 public I_CmsXmlContentContainer contentload(String collectorName, String collectorParam, boolean editable) 085 throws JspException { 086 087 return contentload(collectorName, collectorParam, getRequestContext().getLocale(), editable); 088 } 089 090 /** 091 * Loads a set of <code>{@link org.opencms.xml.I_CmsXmlDocument}</code>, same as 092 * using the <code><cms:contentload collector="***" param="***" locale="***" editable="***" /></code> tag.<p> 093 * 094 * @param collectorName the collector name to use 095 * @param collectorParam the parameters for the collector 096 * @param locale the locale to use to access the content 097 * @param editable indicates if "direct edit" support is required (will insert additional HTML) 098 * 099 * @return an XML content container loaded with the selected content 100 * 101 * @throws JspException in case something goes wrong 102 */ 103 public I_CmsXmlContentContainer contentload( 104 String collectorName, 105 String collectorParam, 106 Locale locale, 107 boolean editable) throws JspException { 108 109 return new CmsJspTagContentLoad(null, getJspContext(), collectorName, collectorParam, locale, editable); 110 } 111 112 /** 113 * Loads a set of <code>{@link org.opencms.xml.I_CmsXmlDocument}</code>, same as 114 * using the <code><cms:contentload collector="***" param="***" locale="***" editable="***" /></code> tag.<p> 115 * 116 * @param collectorName the collector name to use 117 * @param collectorParam the collector param to use 118 * @param pageIndex the display page index (may contain macros) 119 * @param pageSize the display page size (may contain macros) 120 * @param locale the locale to use to access the content 121 * @param editable indicates if "direct edit" support is required (will insert additional HTML) 122 * 123 * @return an XML content container loaded with the selected content 124 * 125 * @throws JspException in case something goes wrong 126 */ 127 public I_CmsXmlContentContainer contentload( 128 String collectorName, 129 String collectorParam, 130 String pageIndex, 131 String pageSize, 132 Locale locale, 133 boolean editable) throws JspException { 134 135 return new CmsJspTagContentLoad( 136 null, 137 getJspContext(), 138 collectorName, 139 collectorParam, 140 pageIndex, 141 pageSize, 142 locale, 143 editable); 144 } 145 146 /** 147 * Enables looping over a list of element values in the given parent container, same as 148 * using the <code><cms:contentloop element="***" /></code> tag.<p> 149 * 150 * @param container the XML content container to read the content from 151 * @param element the element to loop over 152 * 153 * @return an XML content container to be used to loop over the selected element values in the parent container 154 */ 155 public I_CmsXmlContentContainer contentloop(I_CmsXmlContentContainer container, String element) { 156 157 return new CmsJspTagContentLoop(container, element); 158 } 159 160 /** 161 * Returns the currently looped content element String value from the given XML content container, same as 162 * using the <code><cms:contentshow /></code> tag.<p> 163 * 164 * This is to be used with a container initialized by <code>{@link #contentloop(I_CmsXmlContentContainer, String)}</code>, 165 * in this case the element name is already set by the content loop container.<p> 166 * 167 * The locale for accessing the content is read form the current OpenCms users request context.<p> 168 * 169 * @param container the XML content container to read the content from 170 * 171 * @return the selected content element String value from the given XML content container 172 */ 173 public String contentshow(I_CmsXmlContentContainer container) { 174 175 return contentshow(container, null, null); 176 } 177 178 /** 179 * Returns the selected content element String value from the given XML content container, same as 180 * using the <code><cms:contentshow element="***" /></code> tag.<p> 181 * 182 * The locale for accessing the content is read form the current OpenCms users request context.<p> 183 * 184 * @param container the XML content container to read the content from 185 * @param element the element to show 186 * 187 * @return the selected content element String value from the given XML content container 188 */ 189 public String contentshow(I_CmsXmlContentContainer container, String element) { 190 191 return contentshow(container, element, null); 192 } 193 194 /** 195 * Returns the selected content element String value from the given XML content container, same as 196 * using the <code><cms:contentshow element="***" locale="***" /></code> tag.<p> 197 * 198 * @param container the XML content container to read the content from 199 * @param element the element to show 200 * @param locale the locale to read the element from 201 * 202 * @return the selected content element String value from the given XML content container 203 */ 204 public String contentshow(I_CmsXmlContentContainer container, String element, Locale locale) { 205 206 return CmsJspTagContentShow.contentShowTagAction(container, getJspContext(), element, locale, false); 207 } 208}