Wednesday, June 8, 2011

fckeditor

<%
/**
* Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
%>

<%@ include file="/html/common/init.jsp" %>

<%
/**
* This file is part of LiferayUITaglibDemo Liferay plug-in.
*
* LiferayUITaglibDemo Liferay plug-in is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* LiferayUITaglibDemo Liferay plug-in is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with LiferayUITaglibDemo Liferay plug-in. If not, see.
*/
%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

<%@page import="com.liferay.portal.theme.ThemeDisplay"%>
<%@page import="com.liferay.portal.service.ThemeServiceUtil"%>
<%@page import="com.liferay.portal.service.ThemeLocalServiceUtil"%>
<%@page import="com.liferay.portal.kernel.util.KeyValuePair"%>
<%@page import="com.liferay.portlet.journal.model.JournalArticle"%>
<%@page import="com.liferay.portlet.journal.model.JournalArticleModel"%>

<%@ page import="com.liferay.portal.kernel.util.Constants" %>
<%@ page import="com.liferay.portal.kernel.util.ParamUtil" %>
<%@ page import="com.liferay.portal.kernel.util.StringPool" %>
<%@ page import="com.liferay.portal.kernel.util.UnicodeFormatter" %>
<%@ page import="com.liferay.portal.kernel.util.Validator" %>
<%@ page import="com.liferay.portlet.PortletPreferencesFactoryUtil" %>
<%@ page import="com.liferay.portal.util.PortalUtil" %>
<%@ page import="javax.portlet.PortletPreferences" %>
<%@ page import="javax.portlet.PortletRequest" %>

<%@ page import="com.liferay.portal.kernel.util.*" %>
<%@ page import="javax.portlet.WindowState" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.portlet.ActionRequest" %>

<%@page import="java.util.HashSet"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="com.liferay.portal.kernel.util.ParamUtil" %>

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<%@ taglib uri="http://liferay.com/tld/security" prefix="liferay-security" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %>

<%@ page import="com.liferay.portal.kernel.util.Constants" %>
<%@ page import="com.liferay.portal.kernel.util.GetterUtil" %>
<%@ page import="com.liferay.portal.kernel.util.ParamUtil" %>
<%@ page import="com.liferay.portal.kernel.util.StringPool" %>
<%@ page import="com.liferay.portal.kernel.util.Validator" %>
<%@ page import="com.liferay.portal.kernel.search.Hits" %>
<%@ page import="com.liferay.portal.util.PortalUtil" %>
<%@ page import="com.liferay.portlet.PortletPreferencesFactoryUtil" %>
<%@ page import="javax.portlet.PortletPreferences" %>
<%@ page import="javax.portlet.WindowState" %>
<%@ page import="javax.portlet.PortletURL"%>
<%@ page import="javax.portlet.ActionRequest" %>
<%@ page import="javax.portlet.PortletPreferences" %>

<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="com.liferay.portal.kernel.dao.search.ResultRow" %>
<%@ page import="com.liferay.portal.kernel.dao.search.SearchEntry" %>
<%@ page import="com.liferay.portal.kernel.util.DateUtil" %>
<%@ page import="com.liferay.portal.kernel.util.ListUtil" %>

<%--@ page import="com.liferay.portal.kernel.util.WebKeys" --%>
<%@ page import="javax.portlet.PortletSession" %>
<%@ page import="com.liferay.portal.kernel.util.ListUtil" %>
<%@ page import="com.liferay.portal.kernel.language.LanguageUtil" %>
<%@ page import="com.liferay.portal.security.permission.ActionKeys"%>

<%-- Model and Services Imports --%>
<%@ page import="com.ext.portlet.newsletters.model.*" %>
<%@ page import="com.ext.portlet.newsletters.service.*" %>

<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Random" %>

<%
PortletRequest portletRequest = (PortletRequest)request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);

String currentURL = PortalUtil.getCurrentURL(request);

PortletPreferences preferences = renderRequest.getPreferences();

String portletResource = ParamUtil.getString(request, "portletResource");

if (Validator.isNotNull(portletResource)) {
preferences = PortletPreferencesFactoryUtil.getPortletSetup(request, portletResource);
}
//String baumarktActiveMessage = preferences.getValue("baumarktActiveMessage", "");
//String baumarktDefaultMessage = preferences.getValue("baumarktDefaultMessage", "");
//System.out.println("baumarktActiveMessage1"+baumarktActiveMessage);
%>

/*************************************************************View**********************************************************************/
<%@ include file="/html/portlet/ext/newsletters/init.jsp" %>

<%

long id= 0;
String baumarktActiveMessage = "";
String baumarktDefaultMessage = "";

Listbcontent = null;
try {
bcontent = BcontentLocalServiceUtil.getAll();
} catch (Exception e) {
e.printStackTrace();
}

for(Bcontent bcontents : bcontent ){

id = bcontents.getBcontentId();
baumarktActiveMessage = bcontents.getB_activeContent();
baumarktDefaultMessage = bcontents.getB_defaultContent();

}

%>

<form action=""> " name="fm" > <input type="hidden" name="bID" value="" /><%if(baumarktActiveMessage!="" || baumarktActiveMessage.equalsIgnoreCase("null")) {%> <%}else{ %> <%} %> <%if(baumarktDefaultMessage!="" || baumarktDefaultMessage.equalsIgnoreCase("null")) {%> <%}else{ %> <%} %>










Baufachmarkt Active Mail Content



Baufachmarkt Default Mail Content



<input type="button" value=" " onClick="saveMessage();" />// <![CDATA[
function initEditor1() {
return "";
//return null;
}

function initEditor2() {
return "";
}

function saveMessage() {
var baumarktActive = window.baumarktActive.getHTML();
var baumarktDefault = window.baumarktDefault.getHTML();

document.fm.baumarktActiveMessage.value = baumarktActive;
document.fm.baumarktDefaultMessage.value = baumarktDefault;

submitForm(document.fm);
}
// ]]>/***********************************Action*******************************************/ package com.ext.portlet.newsletters.action; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.PortletConfig; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import com.ext.portlet.newsletters.model.Bcontent; import com.ext.portlet.newsletters.model.impl.BcontentImpl; import com.ext.portlet.newsletters.service.BcontentLocalServiceUtil; import com.liferay.portal.kernel.servlet.SessionMessages; import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.util.WebKeys; import com.liferay.portal.struts.PortletAction; import com.liferay.portal.theme.ThemeDisplay; public class AddUpdateBfmContentAction extends PortletAction { public void processAction(ActionMapping mapping, ActionForm form, PortletConfig config, ActionRequest req, ActionResponse res) throws Exception { ThemeDisplay themeDisplay =(ThemeDisplay) req.getAttribute(WebKeys.THEME_DISPLAY); Bcontent bcontent = bcontentFromRequest (req); if(Validator.isNotNull(ParamUtil.getLong(req, "bID")) && ParamUtil.getLong(req, "bID")!=0 ){ Bcontent UpBcontent = BcontentLocalServiceUtil.getAllByID(ParamUtil.getLong(req, "bID")); UpBcontent.setB_activeContent(ParamUtil.getString(req, "baumarktActiveMessage")); UpBcontent.setB_defaultContent(ParamUtil.getString(req, "baumarktDefaultMessage")); UpBcontent.setGroupId(themeDisplay.getScopeGroupId()); BcontentLocalServiceUtil.updateBcontent(UpBcontent, true); SessionMessages.add(req, "bcontent-updated"); } else { BcontentLocalServiceUtil.addContent(bcontent); SessionMessages.add(req, "bcontent-added"); } } private Bcontent bcontentFromRequest(ActionRequest request) { ThemeDisplay themeDisplay =(ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); BcontentImpl bcontent = new BcontentImpl(); bcontent.setB_activeContent(ParamUtil.getString(request, "baumarktActiveMessage")); bcontent.setB_defaultContent(ParamUtil.getString(request, "baumarktDefaultMessage")); bcontent.setGroupId(themeDisplay.getScopeGroupId()); return bcontent; } public ActionForward render( ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { return mapping.findForward("portlet.ext.newsletters.view"); } private static Log _log = LogFactory.getLog(AddUpdateBfmContentAction.class); } /*************************************Service ActionClaa****************************************************/ package com.ext.portlet.newsletters.service.impl; import java.util.List; import com.ext.portlet.newsletters.model.Bcontent; import com.ext.portlet.newsletters.service.base.BcontentLocalServiceBaseImpl; import com.ext.portlet.newsletters.service.persistence.BcontentUtil; import com.liferay.counter.service.CounterLocalServiceUtil; import com.liferay.portal.SystemException; public class BcontentLocalServiceImpl extends BcontentLocalServiceBaseImpl { public List findAllInGroup(long groupId) throws SystemException { List list = (List) BcontentUtil.findByGroupId(groupId); return list; } public List getAll() throws SystemException { return BcontentUtil.findAll(); } public Bcontent getAllByID(long bcontentId ) throws SystemException { return BcontentUtil.fetchByPrimaryKey(bcontentId); } public List getAllContent() throws SystemException { int end =BcontentUtil.countAll(); return BcontentUtil.findAll(0, end); } public Bcontent addContent(Bcontent validBcontent) throws SystemException { Bcontent bcontent = BcontentUtil.create(CounterLocalServiceUtil.increment(Bcontent.class.getName())); bcontent.setGroupId(validBcontent.getGroupId()); bcontent.setB_activeContent(validBcontent.getB_activeContent()); bcontent.setB_defaultContent(validBcontent.getB_defaultContent()); return BcontentUtil.update(bcontent, false); } public void remove(Bcontent bcontent) throws SystemException { BcontentUtil.remove(bcontent); } } /****************************************************service.xml***************************************************/ package com.ext.portlet.newsletters.service.impl; import java.util.List; import com.ext.portlet.newsletters.model.Bcontent; import com.ext.portlet.newsletters.service.base.BcontentLocalServiceBaseImpl; import com.ext.portlet.newsletters.service.persistence.BcontentUtil; import com.liferay.counter.service.CounterLocalServiceUtil; import com.liferay.portal.SystemException; public class BcontentLocalServiceImpl extends BcontentLocalServiceBaseImpl { public List findAllInGroup(long groupId) throws SystemException { List list = (List) BcontentUtil.findByGroupId(groupId); return list; } public List getAll() throws SystemException { return BcontentUtil.findAll(); } public Bcontent getAllByID(long bcontentId ) throws SystemException { return BcontentUtil.fetchByPrimaryKey(bcontentId); } public List getAllContent() throws SystemException { int end =BcontentUtil.countAll(); return BcontentUtil.findAll(0, end); } public Bcontent addContent(Bcontent validBcontent) throws SystemException { Bcontent bcontent = BcontentUtil.create(CounterLocalServiceUtil.increment(Bcontent.class.getName())); bcontent.setGroupId(validBcontent.getGroupId()); bcontent.setB_activeContent(validBcontent.getB_activeContent()); bcontent.setB_defaultContent(validBcontent.getB_defaultContent()); return BcontentUtil.update(bcontent, false); } public void remove(Bcontent bcontent) throws SystemException { BcontentUtil.remove(bcontent); } } Newsletters