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.ade.containerpage; 029 030import org.opencms.ade.containerpage.shared.CmsCntPageData; 031import org.opencms.ade.containerpage.shared.rpc.I_CmsContainerpageService; 032import org.opencms.gwt.CmsGwtActionElement; 033import org.opencms.gwt.CmsRpcException; 034import org.opencms.gwt.shared.CmsCoreData; 035import org.opencms.main.OpenCms; 036import org.opencms.util.CmsRequestUtil; 037 038import javax.servlet.http.HttpServletRequest; 039import javax.servlet.http.HttpServletResponse; 040import javax.servlet.jsp.PageContext; 041 042/** 043 * Action element for container-page editor includes.<p> 044 * 045 * @since 8.0.0 046 */ 047public class CmsContainerpageActionElement extends CmsGwtActionElement { 048 049 /** The OpenCms module name. */ 050 public static final String CMS_MODULE_NAME = "org.opencms.ade.containerpage"; 051 052 /** The GWT module name. */ 053 public static final String GWT_MODULE_NAME = CmsCoreData.ModuleKey.containerpage.name(); 054 055 /** The current container page data. */ 056 private CmsCntPageData m_cntPageData; 057 058 /** 059 * Constructor.<p> 060 * 061 * @param context the JSP page context object 062 * @param req the JSP request 063 * @param res the JSP response 064 */ 065 public CmsContainerpageActionElement(PageContext context, HttpServletRequest req, HttpServletResponse res) { 066 067 super(context, req, res); 068 } 069 070 /** 071 * @see org.opencms.gwt.CmsGwtActionElement#export() 072 */ 073 @Override 074 public String export() throws Exception { 075 076 return ""; 077 } 078 079 /** 080 * @see org.opencms.gwt.CmsGwtActionElement#exportAll() 081 */ 082 @Override 083 public String exportAll() throws Exception { 084 085 CmsRequestUtil.disableCrossSiteFrameEmbedding(getResponse()); 086 StringBuffer sb = new StringBuffer(); 087 sb.append(super.export()); 088 089 String prefetchedData = exportDictionary( 090 CmsCntPageData.DICT_NAME, 091 I_CmsContainerpageService.class.getMethod("prefetch"), 092 getCntPageData()); 093 sb.append(prefetchedData); 094 sb.append(exportModuleScriptTag(GWT_MODULE_NAME)); 095 sb.append("<script src=\""); 096 sb.append( 097 OpenCms.getLinkManager().substituteLinkForRootPath( 098 getCmsObject(), 099 "/system/workplace/editors/tinymce/opencms_plugin.js")); 100 sb.append("\"></script>\n<style type=\"text/css\">\n html {\n overflow-y: scroll;\n }\n</style>"); 101 102 return sb.toString(); 103 } 104 105 /** 106 * Returns the needed server data for client-side usage.<p> 107 * 108 * @return the needed server data for client-side usage 109 */ 110 public CmsCntPageData getCntPageData() { 111 112 if (m_cntPageData == null) { 113 try { 114 m_cntPageData = CmsContainerpageService.prefetch(getRequest()); 115 } catch (@SuppressWarnings("unused") CmsRpcException e) { 116 // ignore, should never happen, and it is already logged 117 } 118 } 119 return m_cntPageData; 120 } 121}