Author: pyaschenko
Date: 2008-09-17 10:23:31 -0400 (Wed, 17 Sep 2008)
New Revision: 10470
Added:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java
Modified:
trunk/sandbox/samples/editor-sample/src/main/webapp/WEB-INF/faces-config.xml
trunk/sandbox/samples/editor-sample/src/main/webapp/editor.xhtml
trunk/sandbox/ui/editor/src/main/templates/editor.jspx
Log:
HTML markup design & Component Base Creation
Modified: trunk/sandbox/samples/editor-sample/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/sandbox/samples/editor-sample/src/main/webapp/WEB-INF/faces-config.xml 2008-09-17
13:40:54 UTC (rev 10469)
+++
trunk/sandbox/samples/editor-sample/src/main/webapp/WEB-INF/faces-config.xml 2008-09-17
14:23:31 UTC (rev 10470)
@@ -7,5 +7,10 @@
<managed-bean-class>org.richfaces.SkinBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>editorBean</managed-bean-name>
+ <managed-bean-class>org.richfaces.EditorBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
</faces-config>
Modified: trunk/sandbox/samples/editor-sample/src/main/webapp/editor.xhtml
===================================================================
(Binary files differ)
Added:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java
(rev 0)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java 2008-09-17
14:23:31 UTC (rev 10470)
@@ -0,0 +1,65 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIParameter;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.richfaces.component.UIEditor;
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+/**
+ * @author Pavel Yaschenko - mailto:pyaschenko@exadel.com created 09.17.2008
+ *
+ */
+public class EditorRendererBase extends HeaderResourcesRendererBase {
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ // TODO Auto-generated method stub
+ return UIEditor.class;
+ }
+
+ public void writeEditorScript(FacesContext context,
+ UIComponent component) throws IOException {
+
+ ResponseWriter writer = context.getResponseWriter();
+ List <UIComponent> children = component.getChildren();
+ Map<String, Object> params = new HashMap<String, Object>();
+ for (UIComponent child: children) {
+ UIParameter c = (UIParameter) child;
+ if (c instanceof UIParameter) {
+ params.put(c.getName(), c.getValue());
+ }
+ }
+ writer.writeText("tinyMCE.init(",null);
+ writer.writeText(ScriptUtils.toScript(params),null);
+ writer.writeText(");",null);
+ }
+}
Modified: trunk/sandbox/ui/editor/src/main/templates/editor.jspx
===================================================================
--- trunk/sandbox/ui/editor/src/main/templates/editor.jspx 2008-09-17 13:40:54 UTC (rev
10469)
+++ trunk/sandbox/ui/editor/src/main/templates/editor.jspx 2008-09-17 14:23:31 UTC (rev
10470)
@@ -6,55 +6,20 @@
xmlns:x="
http://jsf.exadel.com/vcp"
xmlns:u="http://jsf.exadel.com/util"
xmlns:h="http://jsf.exadel.com/header"
- baseclass="org.ajax4jsf.renderkit.HeaderResourcesRendererBase"
- class="org.richfaces.renderkit.html.EditorRenderer">
+ baseclass="org.richfaces.renderkit.EditorRendererBase"
+ class="org.richfaces.renderkit.html.EditorRenderer"
+ component="org.richfaces.component.UIEditor">
<f:clientid var="clientId"/>
<h:styles>css/editor.xcss</h:styles>
<h:scripts>new
org.ajax4jsf.javascript.PrototypeScript(),scripts/tiny_mce/tiny_mce_src.js</h:scripts>
<div id="#{clientId}"
x:passThruWithExclusions="id,value,styleClass,class" class="rich-editor
#{component.attributes['styleClass']}">
-<script language="javascript" type="text/javascript">
- // Notice: The simple theme does not use all options some of them are limited to the
advanced theme
- tinyMCE.init({
- mode : "textareas",
- theme : "advanced",
- plugins :
"table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,media,searchreplace,print,contextmenu,paste,directionality,fullscreen",
- theme_advanced_buttons1_add_before : "save,newdocument,separator",
- theme_advanced_buttons1_add : "fontselect,fontsizeselect",
- theme_advanced_buttons2_add :
"separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
- theme_advanced_buttons2_add_before:
"cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
- theme_advanced_buttons3_add_before : "tablecontrols,separator",
- theme_advanced_buttons3_add :
"emotions,iespell,media,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
- theme_advanced_toolbar_location : "top",
- theme_advanced_toolbar_align : "left",
- theme_advanced_statusbar_location : "bottom",
- content_css : "example_word.css",
- plugi2n_insertdate_dateFormat : "%Y-%m-%d",
- plugi2n_insertdate_timeFormat : "%H:%M:%S",
- external_link_list_url : "example_link_list.js",
- external_image_list_url : "example_image_list.js",
- media_external_list_url : "example_media_list.js",
- file_browser_callback : "fileBrowserCallBack",
- paste_use_dialog : false,
- theme_advanced_resizing : true,
- theme_advanced_resize_horizontal : false,
- theme_advanced_link_targets : "_something=My somthing;_something2=My
somthing2;_something3=My somthing3;",
- paste_auto_cleanup_on_paste : true,
- paste_convert_headers_to_strong : false,
- paste_strip_class_attributes : "all",
- paste_remove_spans : false,
- paste_remove_styles : false
- });
- function fileBrowserCallBack(field_name, url, type, win) {
- // This is where you insert your custom filebrowser logic
- alert("Filebrowser callback: field_name: " + field_name + ", url: "
+ url + ", type: " + type);
+ <script type="text/javascript">
+ <f:call name="writeEditorScript"></f:call>
+ </script>
- // Insert new URL, this would normaly be done in a popup
- win.document.forms[0].elements[field_name].value = "someurl.htm";
- }
-</script>
<textarea id="elm1" name="elm1" rows="15"
cols="80" style="width: 100%">
<p>Some paragraph</p>
<p>Some other paragraph</p>