Author: woonsan
Date: Wed May 19 17:04:13 2010
New Revision: 946281

URL: http://svn.apache.org/viewvc?rev=946281&view=rev
Log:
Adding content body editing feature

Added:
    
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/news-item-header.jsp
   (with props)
    
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/javascript/newsitem-xinha-config.js
   (with props)
Modified:
    
portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
    
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/portlet.xml
    
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/news-item-edit.jsp

Modified: 
portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
URL: 
http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java?rev=946281&r1=946280&r2=946281&view=diff
==============================================================================
--- 
portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
 (original)
+++ 
portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
 Wed May 19 17:04:13 2010
@@ -56,6 +56,13 @@ public class GenericContentPortlet exten
 {
     private static Logger log = 
LoggerFactory.getLogger(GenericContentPortlet.class);
     
+    /**
+     * Name of portlet preference for Header page
+     */
+    public static final String PARAM_HEADER_PAGE = "HeaderPage";
+    
+    protected String defaultHeaderPage = null;
+    
     private String repositoryJndiName = "java:comp/env/jcr/repository";
     private String defaultRepositoryUsername;
     private String defaultRepositoryPassword;
@@ -78,6 +85,8 @@ public class GenericContentPortlet exten
     {
         super.init(config);
         
+        defaultHeaderPage = config.getInitParameter(PARAM_HEADER_PAGE);
+        
         String param = 
StringUtils.trim(getInitParameterFromConfigOrContext(config, 
"repositoryJndiName", null));
         
         if (!StringUtils.isBlank(param))
@@ -157,6 +166,48 @@ public class GenericContentPortlet exten
     }
     
     @Override
+    protected void doHeaders(RenderRequest request, RenderResponse response) 
+    {
+        String headerPage = defaultHeaderPage;
+        
+        String reqHeaderPage = (String) 
request.getAttribute(PARAM_HEADER_PAGE);
+        
+        if (reqHeaderPage != null)
+        {
+            headerPage = reqHeaderPage;
+        }
+        
+        if (allowPreferences)
+        {
+
+            PortletPreferences prefs = request.getPreferences();
+
+            if (prefs != null && reqHeaderPage == null)
+            {
+                headerPage = prefs.getValue(PARAM_HEADER_PAGE, 
defaultHeaderPage);
+            }
+        }
+        
+        if (headerPage != null)
+        {
+            try
+            {
+                
this.getPortletContext().getRequestDispatcher(headerPage).include(request, 
response);
+            }
+            catch (PortletException e)
+            {
+                throw new RuntimeException("Failed to include header page.", 
e);
+            }
+            catch (IOException e)
+            {
+                throw new RuntimeException("Failed to include header page.", 
e);
+            }
+        }
+        
+        super.doHeaders(request, response);
+    }
+    
+    @Override
     protected void doDispatch(RenderRequest request, RenderResponse response) 
throws PortletException, IOException 
     {
         WindowState state = request.getWindowState();

Modified: 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/portlet.xml
URL: 
http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/portlet.xml?rev=946281&r1=946280&r2=946281&view=diff
==============================================================================
--- 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/portlet.xml
 (original)
+++ 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/portlet.xml
 Wed May 19 17:04:13 2010
@@ -233,6 +233,10 @@
     <display-name>News Item Content</display-name>
     
<portlet-class>org.apache.portals.applications.content.GenericContentPortlet</portlet-class>
     <init-param>
+      <name>HeaderPage</name>
+      <value>/WEB-INF/view/news-item-header.jsp</value>
+    </init-param>
+    <init-param>
       <name>ViewPage</name>
       <value>/WEB-INF/view/news-item-view.jsp</value>
     </init-param>

Modified: 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/news-item-edit.jsp
URL: 
http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/news-item-edit.jsp?rev=946281&r1=946280&r2=946281&view=diff
==============================================================================
--- 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/news-item-edit.jsp
 (original)
+++ 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/news-item-edit.jsp
 Wed May 19 17:04:13 2010
@@ -21,21 +21,26 @@ limitations under the License.
 <portlet:defineObjects/>
 <fmt-portlet:setBundle/>
 
-<form method="POST" action="<portlet:actionURL/>">
+<h2>${contentBean.title}</h2>
+<div align="right">${contentBean.documentDate}</div>
+
+<p>&nbsp;</p>
+
 <table>
   <tr>
-    <td>Title:</td>
-    <td><input name="content.title" type="text" size="80" 
value="${contentBean.title}"/></td>
-  </tr>
-  <tr>
-    <td colspan="2">
-      Introduction:<br/>
-      <textarea name="content.introduction" rows="4" 
cols="80">${contentBean.introduction}</textarea>
+    <td class="portlet-section-body">
+      <div>${contentBean.introduction}</div>
     </td>
   </tr>
+</table>
+
+<p>&nbsp;</p>
+
+<form method="POST" action="<portlet:actionURL/>">
+<table>
   <tr>
     <td colspan="2">
-      <textarea name="content.body.content" rows="20" 
cols="80">${contentBean.body.content}</textarea>
+      <textarea id="content.body.content" name="content.body.content" 
rows="30" cols="80" style="WIDTH: 100%">${contentBean.body.content}</textarea>
     </td>
   </tr>
   <tr>

Added: 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/news-item-header.jsp
URL: 
http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/news-item-header.jsp?rev=946281&view=auto
==============================================================================
--- 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/news-item-header.jsp
 (added)
+++ 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/news-item-header.jsp
 Wed May 19 17:04:13 2010
@@ -0,0 +1,57 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+--%>
+<%@ page import="javax.portlet.MimeResponse" %>
+<%@ page import="org.w3c.dom.Element" %>
+<%@ page import="org.w3c.dom.Text" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
+<%@ taglib uri="http://java.sun.com/portlet"; prefix="portlet"%>
+<portlet:defineObjects/>
+
+<%
+String xinhaPath = request.getContextPath() + "/javascript/xinha";
+String xinhaCorePath = xinhaPath + "/XinhaCore.js";
+String editorUrl = xinhaPath + "/";
+String editorLang = "en";
+String editorSkin = "silva";
+String xinhaConfigPath = request.getContextPath() + 
"/javascript/newsitem-xinha-config.js";
+
+Element elem = renderResponse.createElement("script");
+elem.setAttribute("id", "xinha-editor-url");
+elem.setAttribute("language", "JavaScript");
+elem.setAttribute("type", "text/javascript");
+Text text = elem.getOwnerDocument().createTextNode("_editor_url  = '" + 
editorUrl + "'; _editor_lang = '" + editorLang + "'; _editor_skin = '" + 
editorSkin + "'");
+elem.appendChild(text);
+renderResponse.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, elem);
+
+elem = renderResponse.createElement("script");
+elem.setAttribute("id", "xinha-core");
+elem.setAttribute("language", "JavaScript");
+elem.setAttribute("type", "text/javascript");
+elem.setAttribute("src", xinhaCorePath);
+text = elem.getOwnerDocument().createTextNode("");
+elem.appendChild(text);
+renderResponse.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, elem);
+
+elem = renderResponse.createElement("script");
+elem.setAttribute("id", "newsitem-xinha-config");
+elem.setAttribute("language", "JavaScript");
+elem.setAttribute("type", "text/javascript");
+elem.setAttribute("src", xinhaConfigPath);
+text = elem.getOwnerDocument().createTextNode("");
+elem.appendChild(text);
+renderResponse.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, elem);
+%>
\ No newline at end of file

Propchange: 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/news-item-header.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/news-item-header.jsp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/news-item-header.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/javascript/newsitem-xinha-config.js
URL: 
http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/javascript/newsitem-xinha-config.js?rev=946281&view=auto
==============================================================================
--- 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/javascript/newsitem-xinha-config.js
 (added)
+++ 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/javascript/newsitem-xinha-config.js
 Wed May 19 17:04:13 2010
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @version $Id$
+ */
+
+xinha_editors = null;
+xinha_init    = null;
+xinha_config  = null;
+xinha_plugins = null;
+
+// This contains the names of textareas we will make into Xinha editors
+xinha_init = xinha_init ? xinha_init : function()
+{
+   /** STEP 1 ***************************************************************
+   * First, specify the textareas that shall be turned into Xinhas. 
+   * For each one add the respective id to the xinha_editors array.
+   * I you want add more than on textarea, keep in mind that these 
+   * values are comma seperated BUT there is no comma after the last value.
+   * If you are going to use this configuration on several pages with different
+   * textarea ids, you can add them all. The ones that are not found on the
+   * current page will just be skipped.
+   ************************************************************************/
+  
+  xinha_editors = xinha_editors ? xinha_editors :
+  [
+    'content.body.content'
+  ];
+  
+  /** STEP 2 ***************************************************************
+   * Now, what are the plugins you will be using in the editors on this
+   * page.  List all the plugins you will need, even if not all the editors
+   * will use all the plugins.
+   *
+   * The list of plugins below is a good starting point, but if you prefer
+   * a simpler editor to start with then you can use the following 
+   * 
+   * xinha_plugins = xinha_plugins ? xinha_plugins : [ ];
+   *
+   * which will load no extra plugins at all.
+   ************************************************************************/
+
+  xinha_plugins = xinha_plugins ? xinha_plugins :
+  [
+   'CharacterMap',
+   'ContextMenu',
+   'ListType',
+   'Stylist',
+   'Linker',
+   'SuperClean',
+   'TableOperations'
+  ];
+  
+         // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :)
+         if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;
+
+
+  /** STEP 3 ***************************************************************
+   * We create a default configuration to be used by all the editors.
+   * If you wish to configure some of the editors differently this will be
+   * done in step 5.
+   *
+   * If you want to modify the default config you might do something like this.
+   *
+   *   xinha_config = new Xinha.Config();
+   *   xinha_config.width  = '640px';
+   *   xinha_config.height = '420px';
+   *
+   *************************************************************************/
+
+   xinha_config = xinha_config ? xinha_config() : new Xinha.Config();
+   
+  //this is the standard toolbar, feel free to remove buttons as you like
+  xinha_config.toolbar =
+  [
+    ["popupeditor"],
+    
["separator","formatblock","fontname","fontsize","bold","italic","underline","strikethrough"],
+    ["separator","forecolor","hilitecolor","textindicator"],
+    ["separator","subscript","superscript"],
+    
["linebreak","separator","justifyleft","justifycenter","justifyright","justifyfull"],
+    ["separator","insertorderedlist","insertunorderedlist","outdent","indent"],
+    
["separator","inserthorizontalrule","createlink","insertimage","inserttable"],
+    ["linebreak","separator","undo","redo","selectall","print"], 
(Xinha.is_gecko ? [] : ["cut","copy","paste","overwrite","saveas"]),
+    
["separator","killword","clearfonts","removeformat","toggleborders","splitblock","lefttoright",
 "righttoleft"],
+    ["separator","htmlmode","showhelp","about"]
+  ];
+
+        
+   // To adjust the styling inside the editor, we can load an external 
stylesheet like this
+   // NOTE : YOU MUST GIVE AN ABSOLUTE URL
+  
+   xinha_config.pageStyleSheets = [ _editor_url + "examples/full_example.css" 
];
+
+  /** STEP 4 ***************************************************************
+   * We first create editors for the textareas.
+   *
+   * You can do this in two ways, either
+   *
+   *   xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, 
xinha_plugins);
+   *
+   * if you want all the editor objects to use the same set of plugins, OR;
+   *
+   *   xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config);
+   *   xinha_editors.myTextArea.registerPlugins(['Stylist']);
+   *   xinha_editors.anotherOne.registerPlugins(['CSS','SuperClean']);
+   *
+   * if you want to use a different set of plugins for one or more of the
+   * editors.
+   ************************************************************************/
+
+  xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, 
xinha_plugins);
+
+  /** STEP 5 ***************************************************************
+   * If you want to change the configuration variables of any of the
+   * editors,  this is the place to do that, for example you might want to
+   * change the width and height of one of the editors, like this...
+   *
+   *   xinha_editors.myTextArea.config.width  = '640px';
+   *   xinha_editors.myTextArea.config.height = '480px';
+   *
+   ************************************************************************/
+
+
+  /** STEP 6 ***************************************************************
+   * Finally we "start" the editors, this turns the textareas into
+   * Xinha editors.
+   ************************************************************************/
+
+  Xinha.startEditors(xinha_editors);
+}
+
+Xinha._addEvent(window,'load', xinha_init); // this executes the xinha_init 
function on page load 
+                                            // and does not interfere with 
window.onload properties set by other scripts
\ No newline at end of file

Propchange: 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/javascript/newsitem-xinha-config.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/javascript/newsitem-xinha-config.js
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: 
portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/javascript/newsitem-xinha-config.js
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to