You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2006/05/03 23:24:58 UTC

svn commit: r399437 [2/4] - in /myfaces/tomahawk/trunk/sandbox/core/src/main: java/org/apache/myfaces/custom/pagelet/ resources/org/apache/myfaces/custom/pagelet/resource/ resources/org/apache/myfaces/custom/pagelet/resource/css/ resources/org/apache/m...

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererPagelet.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererPagelet.java?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererPagelet.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererPagelet.java Wed May  3 14:24:53 2006
@@ -0,0 +1,407 @@
+package org.apache.myfaces.custom.pagelet;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.myfaces.custom.dojo.DojoConfig;
+import org.apache.myfaces.custom.dojo.DojoUtils;
+import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
+import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+
+
+/**
+ * Refactored subrenderer for the pagelet mode
+ * of the pagelet component
+ * this class renders only the rich edit paglet mode part
+ * of the component
+ *
+ * @author werpu
+ *
+ */
+public class SubrendererPagelet extends BasePageletRenderer {
+
+    public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
+        encodeEndPagelet(facesContext, uiComponent);
+
+    }
+
+    /**
+     * general pagelet encoding, can be shared among all pagelet types
+     *
+     * @param facesContext
+     * @param uiComponent
+     */
+    public void encodeJavascript(FacesContext facesContext, UIComponent uiComponent) throws IOException {
+        Pagelet control = (Pagelet) uiComponent;
+
+        String javascriptLocation = (String) control.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
+
+        AddResource addResource = AddResourceFactory.getInstance(facesContext);
+
+        if (javascriptLocation != null)
+            addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, javascriptLocation + "utils.js");
+        else
+            addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, Pagelet.class, "utils.js");
+
+        DojoUtils.addMainInclude(facesContext, uiComponent, javascriptLocation, new DojoConfig());
+
+        DojoUtils.addRequire(facesContext, uiComponent, "dojo.event.*");
+        DojoUtils.addRequire(facesContext, uiComponent, "dojo.html");
+        DojoUtils.addRequire(facesContext, uiComponent, "dojo.widget.Editor");
+
+        DojoUtils.addRequire(facesContext, uiComponent, "dojo.widget.Dialog");
+        DojoUtils.addRequire(facesContext, uiComponent, "dojo.widget.Tooltip");
+
+        // todo until we have a a new version of myfaces
+        ResponseWriter writer = facesContext.getResponseWriter();
+
+        writer.startElement(HTML.SCRIPT_ELEM, uiComponent);
+        writer.writeAttribute(HTML.TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
+        
+        writer.write("dojo.hostenv.setModulePrefix('org.apache.myfaces.pagelet', '../pagelet.PageletRenderer/');\n");
+        writer.endElement(HTML.SCRIPT_ELEM);
+
+        if (!control.isReadonly() && !control.isDisabled())
+            DojoUtils.addRequire(facesContext, uiComponent, "org.apache.myfaces.pagelet.MyFacesHiddenRichText");
+
+        DojoUtils.addRequire(facesContext, uiComponent, "dojo.fx.html");
+        DojoUtils.addRequire(facesContext, uiComponent, "dojo.event.*");
+
+        if (!DojoUtils.isInlineScriptSet(facesContext, "progressor.js"))
+            addResource.addJavaScriptHere(facesContext, PageletRenderer.class, "progressor.js");
+
+        if (!DojoUtils.isInlineScriptSet(facesContext, "pagelet.js"))
+            addResource.addJavaScriptHere(facesContext, PageletRenderer.class, "pagelet.js");
+
+        String styleLocation = (String) uiComponent.getAttributes().get(JSFAttr.STYLE_LOCATION);
+
+        // we some styles for the notifier subsystem
+        if (StringUtils.isNotBlank(styleLocation)) {
+            addResource.addStyleSheet(facesContext, AddResource.HEADER_BEGIN, styleLocation + "/pagelet.css");
+        } else {
+            addResource.addStyleSheet(facesContext, AddResource.HEADER_BEGIN, PageletRenderer.class, "css/pagelet.css");
+        }
+
+        DojoUtils.addRequire(facesContext, uiComponent, "org.apache.myfaces.pagelet.*");
+
+    }
+
+    public void encodeJavascriptEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
+        Pagelet spchk = (Pagelet) uiComponent;
+
+        /*
+         *
+         * var dlg, dlg2; var evtHandler, evtHandler2;
+         *
+         * evtHandler = new
+         * myfaces_Pagelet("evtHandler","DialogContent",'sensitiveField',
+         * 'DialogContent_editor' );
+         * dojo.event.connect(dojo.byId('sensitiveField'), "onclick",
+         * evtHandler, "onShowdlg");
+         * dojo.event.connect(dojo.byId('DialogContent_submitter'), "onclick",
+         * evtHandler, "onDlgClose");
+         * dojo.event.connect(dojo.byId('DialogContent_speller'),"onclick",
+         * evtHandler, "onSpellCheck");
+         * dojo.event.connect(dojo.byId('DialogContent_clear'),"onclick",
+         * evtHandler, "onCleanup");
+         *
+         */
+        String         uniqueId         = calcUniqueId(uiComponent, facesContext);
+        ResponseWriter writer           = facesContext.getResponseWriter();
+        String         dialogId         = getPageletDialogId(uniqueId);
+        String         eventHandlerId   = getPageletEventhandlerId(uniqueId);
+        String         internalEditorId = getPageletEditorId(dialogId);
+        String         btsubmitterId    = getPageletSubmitterId(dialogId);
+        String         btspellerId      = getPageletSpellerId(dialogId);
+        String         btcancelId       = getPageletCancelId(dialogId);
+        String         btclearId        = getPageletClearId(dialogId);
+        String         methodBinding    = ((Pagelet) uiComponent).getSpellchecker().getExpressionString();
+
+        writer.startElement("script", uiComponent);
+        writer.writeAttribute("type", "text/javascript", null);
+
+        // for inline editing
+        writer.write("	var " + uniqueId + " = dojo.byId('" + uniqueId + "');\n");
+
+        if (!spchk.isReadonly() && !spchk.isDisabled()) {
+            writer.write("dojo.lang.setTimeout( function () { \n");
+            writer.write(" var editor = dojo.widget.createWidget('MyFacesHiddenRichText', { widgetId:'" + uniqueId + "RichText' }, " + uniqueId + ");}, 0); \n");
+        }
+
+        // normal pagelet instantiation part
+        writer.write("var " + uniqueId + "var;\n");
+        writer.write("var " + eventHandlerId + ";\n");
+        writer.write(uniqueId + "EvtHandler = new myfaces_Pagelet(\"" + uniqueId + "EvtHandler\",\"" + dialogId + "\",'" + uniqueId + "', '" + internalEditorId + "','" + getSpellcheckServletPath(facesContext) + "', '" + methodBinding + "'," + spchk.isReadonly() + ", '" + spchk.getControlMode() + "' );\n");
+
+        if (!spchk.isDisabled()) {
+
+            if (spchk.isReadonly())
+                writer.write(" dojo.event.connect(dojo.byId('" + btsubmitterId + "'), \"onclick\", " + eventHandlerId + ", \"onDlgCancel\");\n");
+
+            if (!spchk.isReadonly()) {
+                writer.write(" dojo.event.connect(dojo.byId('" + btsubmitterId + "'), \"onclick\", " + eventHandlerId + ", \"onDlgClose\");\n");
+                writer.write(" dojo.event.connect(dojo.byId('" + btcancelId + "'), \"onclick\", " + eventHandlerId + ", \"onDlgCancel\");\n");
+                writer.write(" dojo.event.connect(dojo.byId('" + btspellerId + "'),\"onclick\", " + eventHandlerId + ", \"onSpellCheck\");\n");
+                writer.write(" dojo.event.connect(dojo.byId('" + btclearId + "'),\"onclick\", " + eventHandlerId + ", \"onCleanup\");\n");
+            }
+        }
+
+        writer.endElement("script");
+    }
+
+    /**
+     * Read only pagelet encoding
+     *
+     * @param facesContext
+     * @param uiComponent
+     * @throws IOException
+     */
+    private void encodeEndPagelet(FacesContext facesContext, UIComponent uiComponent) throws IOException {
+        RendererUtils.checkParamValidity(facesContext, uiComponent, Pagelet.class);
+
+        if (!uiComponent.isRendered())
+            return;
+
+        String uniqueId = calcUniqueId(uiComponent, facesContext);
+
+        // we have to shift the value binding in the decode from the back into
+        // the value
+        String         dialogId        = getPageletDialogId(uniqueId);
+        String         backupControlId = getPageletBackupControlId(uniqueId);
+        String         eventHandlerId  = getPageletEventhandlerId(uniqueId);
+        ResponseWriter writer          = facesContext.getResponseWriter();
+
+        renderPageletPageSingleton(facesContext, uiComponent, writer);
+
+        Pagelet spchk = (Pagelet) uiComponent;
+        encodeJavascript(facesContext, uiComponent);
+
+        /*
+         * the main holder component <input type="hidden"
+         * id="sensitiveField2_back" /> <div id="sensitiveField2"
+         * style="background-color: lightGrey; width: 200px; height: 200px;
+         * overflow: auto;"> hello snafu world </div>
+         */
+        String style      = (String) uiComponent.getAttributes().get("style");
+        String styleClass = (String) uiComponent.getAttributes().get("styleClass");
+
+        Integer width  = (Integer) uiComponent.getAttributes().get("width");
+        Integer height = (Integer) uiComponent.getAttributes().get("height");
+
+        width  = (width == null) ? new Integer(200) : width;
+        height = (height == null) ? new Integer(200) : height;
+
+        if (style == null)
+            style = "width: " + width.toString() + "px; height: " + height.toString() + "px; overflow: auto;";
+
+        writePageletDialog(facesContext, uiComponent, dialogId, writer);
+
+        writer.startElement("input", uiComponent);
+        writer.writeAttribute("type", "hidden", null);
+        writer.writeAttribute("id", backupControlId, null);
+        writer.writeAttribute("name", backupControlId, null);
+
+        String strValue = org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.getStringValue(facesContext, uiComponent);
+        writer.writeAttribute("value", strValue, org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr.VALUE_ATTR);
+
+        writer.endElement("input");
+
+        startWriterPositioningTable(writer);
+        startContentColum(writer);
+
+        writer.startElement(HTML.DIV_ELEM, uiComponent);
+        writer.writeAttribute(HTML.ID_ATTR, uniqueId, null);
+        writer.writeAttribute("style", style, null);
+
+        if (styleClass != null)
+            writer.writeAttribute("class", styleClass, null);
+        else if (!spchk.isDisabled() && !spchk.isReadonly())
+            writer.writeAttribute("class", "pagelet", null);
+        else if (spchk.isDisabled())
+            writer.writeAttribute("class", "pagelet_inactive", null);
+        else
+            writer.writeAttribute("class", "pagelet_readonly", null);
+
+        writer.endElement(HTML.DIV_ELEM);
+        endContentColum(writer);
+        startPositionColumn(writer);
+
+        if ((spchk.getLinkZoom() != null) && !spchk.isDisabled()) {
+
+            // resizer
+            writer.startElement(HTML.DIV_ELEM, null);
+            writer.startElement(HTML.DIV_ELEM, null);
+            writer.writeAttribute(HTML.ID_ATTR, uniqueId + "zoomer", null);
+            RendererUtils.renderChild(facesContext, spchk.getLinkZoom());
+            writer.endElement(HTML.DIV_ELEM);
+            writeBR(writer);
+            writeResizerLinks(writer, facesContext, spchk, uniqueId, uniqueId + "resizer", null, spchk.getLinkResize() != null, false);
+            writeBR(writer);
+            writer.endElement(HTML.DIV_ELEM);
+        }
+
+        endPositionColumn(writer);
+        endWriterPositioningTable(writer);
+
+        writer.startElement("script", uiComponent);
+        writer.writeAttribute("type", "text/javascript", null);
+        writer.write("var " + uniqueId + "_filler = dojo.byId('" + uniqueId + "'); \n");
+        writer.write(uniqueId + "_filler.innerHTML = unescape('" + StringEscapeUtils.escapeJavaScript(strValue) + "');");
+        writer.endElement("script");
+
+        encodeJavascriptEnd(facesContext, uiComponent);
+
+        if (!spchk.isDisabled()) {
+
+            // now do the special link encoding
+            writer.startElement("script", uiComponent);
+            writer.writeAttribute("type", "text/javascript", null);
+
+            // direct click
+            if (spchk.getLinkZoom() == null)
+                writer.write("dojo.event.connect(dojo.byId(\"" + uniqueId + "\"), \"onclick\", " + eventHandlerId + ", \"onShowdlg\");\n");
+
+            // zoom button
+            else
+                writer.write("dojo.event.connect(dojo.byId(\"" + uniqueId + "zoomer\"), \"onclick\", " + eventHandlerId + ", \"onShowdlg\");\n");
+
+            writer.endElement("script");
+        }
+    }
+
+    /**
+     * renders the pagelet page singleton part this part is only rendered once
+     * and used by all pagelet in a shared manner it for now is mainly only the
+     * initializer code for the progress display and the floating suggestion
+     * list
+     *
+     * @param facesContext
+     * @param uiComponent
+     * @param writer
+     * @throws IOException
+     */
+    private void renderPageletPageSingleton(FacesContext facesContext, UIComponent uiComponent, ResponseWriter writer) throws IOException {
+
+        // first render generalPageletStructure
+        if (((HttpServletRequest) facesContext.getExternalContext().getRequest()).getAttribute("PAGELET_CORE_SINGLETON") == null) {
+
+            // initialize the core singletoned code for this component
+            ((HttpServletRequest) facesContext.getExternalContext().getRequest()).setAttribute("PAGELET_CORE_SINGLETON", new Boolean(true));
+
+            // write the tooltip for the spellcheck results first
+            writer.startElement("div", uiComponent);
+            writer.writeAttribute("id", "dojoDialog_spellcheckResults", null);
+            writer.writeAttribute("style", "position:fixed;width:600px;left:20;top:20; visibility:hidden;", null);
+            writer.write("results");
+            writer.endElement("div");
+
+            // in progress page part
+            writer.startElement("div", uiComponent);
+            writer.writeAttribute("id", "dojoDialog_inprogress", null);
+            writer.writeAttribute("style",
+                "position:absolute; width: 100px;left:0;top:0;background-color: red;visibility: hidden; z-index: 999;", null);
+            writer.write("Please wait");
+            writer.endElement("div");
+        }
+    }
+
+    /**
+     * writes the pagelet dialog subsystem this is the rendering code utilized
+     * as the main dialog for the html editor of the pagelet
+     *
+     * @param uiComponent
+     * @param dialogId
+     * @param writer
+     * @throws IOException
+     */
+    private void writePageletDialog(FacesContext facesContext, UIComponent uiComponent, String dialogId, ResponseWriter writer)
+        throws IOException {
+
+        /*
+         * <div class="dojoDialogSpeller" id="DialogContent2"
+         * style="position:absolute;width:600px;left:20;top:20;background-color:
+         * lightGrey; visibility: hidden; "> <TEXTAREA
+         * id="DialogContent2_editor"></TEXTAREA> <button
+         * id="DialogContent2_submitter"> [ok] </button> <button
+         * id="DialogContent2_speller"> [spell] </button> <button
+         * id="DialogContent2_clear"> [clear] </button> </div>
+         */
+        Pagelet spchk = (Pagelet) uiComponent;
+
+        String internalEditorId = getPageletEditorId(dialogId);
+        String btsubmitterId    = getPageletSubmitterId(dialogId);
+        String btspellerId      = getPageletSpellerId(dialogId);
+        String btcancelId       = getPageletCancelId(dialogId);
+        String btclearId        = getPageletClearId(dialogId);
+
+        String style = "visibility: hidden; background-color: #fff;text-align: left;";
+
+        String buttonStyle    = "cursor: pointer;float: right; font-weight: bold; position: relative; right: auto;";
+        String buttonBarStyle = "background-color: rgb(204,204,255); width: 100%; position: relative; bottom: 0px;";
+        // String buttonBarStyle = "";
+
+        writer.startElement("div", uiComponent);
+        writer.writeAttribute("class", "dojoDialogSpeller", null);
+        writer.writeAttribute("id", dialogId, null);
+        writer.writeAttribute("style", style, null);
+        writer.startElement("div", uiComponent);
+        writer.writeAttribute("id", internalEditorId, null);
+        writer.endElement("div");
+
+        AddResource addResource = AddResourceFactory.getInstance(facesContext);
+
+        writer.startElement("div", uiComponent);
+        writer.writeAttribute("style", buttonBarStyle, null);
+
+        writer.startElement("table", uiComponent);
+        writer.writeAttribute("width", "50%", null);
+        writer.writeAttribute("style", "float:left;", null);
+        writer.startElement("tr", uiComponent);
+
+        if (spchk.getLinkPopupLabel() != null) {
+            writer.startElement("td", uiComponent);
+            writer.writeAttribute("align", "left", null);
+
+            RendererUtils.renderChild(facesContext, spchk.getLinkPopupLabel());
+            writer.endElement("td");
+        }
+
+        writer.endElement("tr");
+        writer.endElement("table");
+
+        writer.startElement("table", uiComponent);
+        writer.writeAttribute("width", "40%", null);
+        writer.writeAttribute("style", "float:right;", null);
+        writer.startElement("tr", uiComponent);
+
+        writer.startElement("td", uiComponent);
+        writer.writeAttribute("align", "right", null);
+
+        if (!spchk.isReadonly()) {
+
+            writeClearImage(facesContext, uiComponent, writer, btclearId, buttonStyle, addResource);
+            writeCancelImg(facesContext, uiComponent, writer, btcancelId, buttonStyle, addResource);
+            writeSpellcheckImage(facesContext, uiComponent, writer, btspellerId, buttonStyle, addResource);
+
+        }
+
+        writeOkImage(facesContext, uiComponent, writer, btsubmitterId, buttonStyle, addResource);
+
+        writer.endElement("td");
+        writer.endElement("tr");
+        writer.endElement("table");
+
+        writer.endElement("div");
+        writer.endElement("div");
+    }
+
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererPageletRawText.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererPageletRawText.java?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererPageletRawText.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererPageletRawText.java Wed May  3 14:24:53 2006
@@ -0,0 +1,305 @@
+package org.apache.myfaces.custom.pagelet;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
+import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+
+
+/**
+ * A subrenderer rendering the raw text component
+ * @author werpu
+ *
+ */
+public class SubrendererPageletRawText extends SubrendererTextarea {
+
+    /**
+    * encode end for the basic text area functionality
+    * @param facesContext
+    * @param uiComponent
+    * @throws IOException
+    */
+    protected void encodeEndTextarea(FacesContext facesContext, UIComponent uiComponent) throws IOException {
+        RendererUtils.checkParamValidity(facesContext, uiComponent, Pagelet.class);
+
+        if (!uiComponent.isRendered())
+            return;
+
+        Pagelet spchk = (Pagelet) uiComponent;
+        encodeJavascript(facesContext, uiComponent);
+
+        ResponseWriter writer = facesContext.getResponseWriter();
+
+        String uniqueId = calcUniqueId(uiComponent, facesContext);
+
+        writeTextArea(facesContext, spchk, writer, uniqueId, false);
+        writeRawTextDialog(facesContext, spchk, writer);
+        // end control panel
+    }
+
+
+    protected void writeTextRawTextDialogTA(FacesContext facesContext, Pagelet spchk, ResponseWriter writer, String uniqueId,
+            boolean asDialog) throws IOException {
+        String divId      = uniqueId + DIV_ID_SUFFIX;
+        String varName    = uniqueId + TEXTBOX_ID_SUFFIX;
+        String textAreaId = uniqueId + TEXT_AREA_SUFFIX;
+        String editDivId  = uniqueId + EDIT_DIV_SUFFIX;
+        String formName   = uniqueId + FORM_SUFFIX;
+
+        String methodBinding = spchk.getSpellchecker().getExpressionString();
+
+
+        if (spchk.isDisplayValueOnly()) {
+            writer.startElement("div", null);
+            HtmlRendererUtils.writeIdIfNecessary(writer, spchk, facesContext);
+
+            String style = "width:" + spchk.getWidth() + "px;" + "heigth:" + spchk.getHeight() + "px;" + spchk.getDisplayValueOnlyStyle();
+
+            writer.writeAttribute("style", style, null);
+
+            if (spchk.getDisplayValueOnlyStyleClass() != null)
+                writer.writeAttribute("class", spchk.getDisplayValueOnlyStyleClass(), null);
+                //TODO add the dialog handling here
+
+            String strValue = RendererUtils.getStringValue(facesContext, spchk);
+            writer.writeText(strValue, JSFAttr.VALUE_ATTR);
+            writer.endElement("div");
+
+            return;
+        }
+
+        // control panel
+
+        // positioning table
+        startControlPanel(writer, divId);
+
+        // textarea
+        writeTextarea(writer, textAreaId, spchk, formName);
+
+        // edit div
+        writeEditDiv(writer, spchk, editDivId);
+        endControlPanel(writer);
+    }
+
+
+    private void writeActionButtons(boolean writeLinks, ResponseWriter writer, String varName, FacesContext facesContext,
+            Pagelet spchk, String resizerId) throws IOException {
+
+        if (writeLinks) {
+            AddResource addResource = AddResourceFactory.getInstance(facesContext);
+
+            String uniqueId      = calcUniqueId(spchk, facesContext);
+            String linkSpellchId = uniqueId + "spellchk"; // TODO unique
+            String linkResumeId  = uniqueId + "resume"; // TODO unique
+            writer.startElement("div", null);
+            writer.writeAttribute("id", linkSpellchId, null);
+            writer.writeAttribute(HTML.STYLE_ATTR, "float:right;", null);
+            writer.writeAttribute("onclick", "displayInline('" + linkResumeId + "');setCurrentObject(" + varName + ");" + varName + ".spellCheck();displayNone('" + linkSpellchId + "');displayNone('" + resizerId + "');", null);
+            writer.startElement("img", spchk);
+            writer.writeAttribute("alt", "[Spellcheck]", null);
+            writer.writeAttribute("src", addResource.getResourceUri(facesContext, PageletRenderer.class, "img/SPELLCHECK_0.gif"), null);
+            writer.endElement("img");
+            writer.endElement("div");
+            writer.startElement("div", null);
+            writer.writeAttribute("id", linkResumeId, null);
+            writer.writeAttribute("style", "display:none;float: right;", null);
+            writer.writeAttribute("onclick", "displayInline('" + linkSpellchId + "');setCurrentObject(" + varName + ");" + varName + ".resumeEditing();displayNone('" + linkResumeId + "');displayInline('" + resizerId + "');", null);
+            writer.startElement("img", spchk);
+            writer.writeAttribute("alt", "[Resume]", null);
+            writer.writeAttribute("src", addResource.getResourceUri(facesContext, PageletRenderer.class, "img/RESUME_0.gif"), null);
+            writer.endElement("img");
+            writer.endElement("div");
+        }
+    }
+
+
+    private void writeActionLinksRawText(FacesContext facesContext, Pagelet spchk, ResponseWriter writer, String uniqueId,
+            boolean asDialog) throws IOException {
+        String divId      = uniqueId + DIV_ID_SUFFIX;
+        String varName    = uniqueId + TEXTBOX_ID_SUFFIX;
+        String textAreaId = uniqueId + TEXT_AREA_SUFFIX;
+        String formName   = uniqueId + FORM_SUFFIX;
+
+
+        String actionSpanId = getActionSpanId(uniqueId);
+        String resizeSpanId = getResizeId(uniqueId);
+        String statusSpanId = getStatusSpanId(uniqueId);
+
+        boolean writeLinks    = (spchk.getLinkSpellchecker() != null) && (spchk.getLinkResume() != null) && !spchk.isDisabled() && !spchk.isReadonly();
+        String  methodBinding = spchk.getSpellchecker().getExpressionString();
+
+        writeActionButtons(writeLinks, writer, varName, facesContext, spchk, resizeSpanId);
+        writeEmptyFloatRight(spchk, writer);
+        writeStatusSpanRawText(writer, statusSpanId);
+        writeScript(writer, spchk, facesContext, varName, spchk, divId, formName, actionSpanId, statusSpanId, textAreaId, methodBinding,
+            writeLinks);
+
+    }
+
+    private void writeRawTextDialog(FacesContext facesContext, Pagelet spchk, ResponseWriter writer) throws IOException {
+
+        if (spchk.isDisabled())
+            return; //no dialog at raw text
+
+        String uniqueId = calcUniqueId(spchk, facesContext);
+        /*we are in rawtext mode we need a new dialog system as well*/
+
+
+        String dialogId         = uniqueId + "Dialog";
+        String okId             = dialogId + "Ok";
+        String cancelId         = dialogId + "Cancel";
+        String dialogContentId  = uniqueId + "DlgContent";
+        String sourceTextAreaId = uniqueId + TEXT_AREA_SUFFIX;
+        String textAreaId       = dialogContentId + TEXT_AREA_SUFFIX;
+        String correctionDiv    = dialogContentId + EDIT_DIV_SUFFIX;
+        String statusSpanId     = getStatusSpanId(uniqueId);
+        String linkSpellchId    = uniqueId + "spellchk"; // TODO unique
+        String linkResumeId     = uniqueId + "resume"; // TODO unique
+
+
+        String varName = dialogContentId + TEXTBOX_ID_SUFFIX;
+
+        writer.startElement(HTML.SCRIPT_ELEM, spchk);
+        writer.writeAttribute(HTML.TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
+
+        writer.write("var " + dialogId + " = null;\n");
+
+        /*function idJsp0_ajax_spellchecker1_div_zoomOn() {
+                        var textArea = dojo.byId('idJsp0_ajax_spellchecker1_ta');
+
+                    var viewport_size   = dojo.html.getViewportSize();
+
+                    textArea.style.width        = (parseInt(viewport_size[0] ) - 120)+"px";
+                    textArea.style.height       = (parseInt(viewport_size[1] ) - 120)+"px";
+
+                        dlg.show();
+                        dojo.byId('idJsp0_ajax_spellchecker1_ta').value = dojo.byId('idJsp0_ajax_spellchecker0_ta').value;
+                }*/
+        writer.write("function " + dialogId + "_zoomOn() { \n");
+        /*      if(idJsp0_ajax_spellchecker8Dialog == null)
+                idJsp0_ajax_spellchecker8Dialog = dojo.widget.createWidget("Dialog",{},dojo.byId("idJsp0_ajax_spellchecker8Dialog"));
+                */
+
+
+        writer.write("	var textArea = dojo.byId('" + textAreaId + "');\n");
+        writer.write("	var viewport_size 	= dojo.html.getViewportSize();\n");
+        writer.write(" textArea.style.width 	= (parseInt(viewport_size[0] ) - 120)+'px';\n");
+        writer.write("	textArea.style.height	= (parseInt(viewport_size[1] ) - 120)+'px';\n");
+
+        writer.write(dialogId + ".show();\n");
+        writer.write("//double call due to weird ie timing issues\n");
+        writer.write(dialogId + ".show();\n");
+        writer.write(" if(dojo.byId('" + textAreaId + "') != null && dojo.byId('" + textAreaId + "').style.visibility != 'hidden') \n");
+
+        if (!spchk.isReadonly()) {
+            writer.write(" try { \n");
+            writer.write(varName + ".resetSpellChecker();\n");
+            writer.write("displayNone('" + linkResumeId + "');\n");
+            writer.write("displayInline('" + linkSpellchId + "');\n");
+            writer.write(" } catch (e) {};\n");
+
+
+        }
+
+        writer.write(" 	dojo.byId('" + textAreaId + "').value = dojo.byId('" + sourceTextAreaId + "').value;\n");
+        writer.write(" try { \n");
+        writer.write(" 		dojo.byId('" + textAreaId + "').focus();");
+        writer.write(" } catch (e) {};\n");
+        //writer.write("        dojo.byId('" + correctionDiv + "').innerHTML = dojo.byId('" + sourceTextAreaId + "').value;\n");
+        //writer.write(" } catch (e) {};\n");
+
+
+        writer.write("}\n");
+
+        /*function idJsp0_ajax_spellchecker1_div_zoomOff() {
+                        dojo.byId('idJsp0_ajax_spellchecker0_ta').value = dojo.byId('idJsp0_ajax_spellchecker1_ta').value;
+                        dlg.hide();
+                }*/
+        writer.write("function " + dialogId + "_zoomOff() { \n");
+        writer.write("	dojo.byId('" + sourceTextAreaId + "').value = dojo.byId('" + textAreaId + "').value;");
+        writer.write(dialogId + ".hide();\n");
+        writer.write("	dojo.byId('" + sourceTextAreaId + "').focus();");
+
+        writer.write("}\n");
+        //TODO we have to move this into the core code
+        //but for now we leave it this way, but
+        //it has to be moved into the pure javascript core code
+        //to reduce the code bloat
+
+        /*
+                function init() {
+                                dlg = dojo.widget.byId("idJsp0_ajax_spellchecker1_div");
+                                var btn  = dojo.byId("cancelx");
+                                var btn2 = dojo.byId("okx");
+                                //dojo.byId('idJsp0_ajax_spellchecker1_ta').setAttribute("dojoType", "resizabletextarea");
+                                dojo.event.connect(btn, "onclick", dlg, "hide");
+                                dojo.event.connect(btn2, "onclick","idJsp0_ajax_spellchecker1_div_zoomOff");
+                                dojo.event.connect(dojo.byId('zoombt'), "onclick", 'idJsp0_ajax_spellchecker1_div_zoomOn');
+                        }
+                        setTimeout("init()",0);
+         */
+        String zoomSpanId = getZoomId(uniqueId);
+        writer.write(" function " + dialogId + "_init() {\n");
+
+        //writer.write(" " + dialogId + " = dojo.widget.byId('" + dialogId + "');\n");
+        writer.write(" dojo.event.connect(dojo.byId('" + zoomSpanId + "'), 'onclick', '" + dialogId + "_zoomOn');\n");
+        writer.write(" dojo.event.connect(dojo.byId('" + okId + "'), 'onclick', '" + dialogId + "_zoomOff');\n");
+
+        writer.write("   " + dialogId + " = dojo.widget.createWidget('Dialog',{},dojo.byId('" + dialogId + "'));\n");
+        writer.write(" dojo.event.connect(dojo.byId('" + cancelId + "'), 'onclick'," + dialogId + ", 'hide');\n");
+
+        //TODO do the event connectors to all this, ok and cancel are still missing
+        writer.write("}\n");
+        writer.write(" setTimeout('" + dialogId + "_init()',1000);\n");
+        writer.endElement(HTML.SCRIPT_ELEM);
+
+        writer.startElement(HTML.DIV_ELEM, spchk);
+        writer.writeAttribute(HTML.ID_ATTR, dialogId, null);
+        writer.writeAttribute(HTML.STYLE_ATTR, "visibility: hidden;", null);
+        writeTextRawTextDialogTA(facesContext, spchk, writer, dialogContentId, true);
+
+
+        writer.startElement(HTML.DIV_ELEM, spchk);
+
+        {
+
+            if (spchk.getLinkPopupLabel() != null) {
+                RendererUtils.renderChild(facesContext, spchk.getLinkPopupLabel());
+            }
+
+            AddResource addResource = AddResourceFactory.getInstance(facesContext);
+
+            writeEmptyFloatRight(spchk, writer);
+            writeOkImage(facesContext, spchk, writer, okId, "float:right;", addResource);
+            writeEmptyFloatRight(spchk, writer);
+            writeCancelImg(facesContext, spchk, writer, cancelId, "float:right;", addResource);
+            writeEmptyFloatRight(spchk, writer);
+            writeActionLinksRawText(facesContext, spchk, writer, dialogContentId, true);
+
+
+        }
+
+        writer.endElement(HTML.DIV_ELEM);
+
+        writer.endElement(HTML.DIV_ELEM);
+
+    }
+
+    private void writeStatusSpanRawText(ResponseWriter writer, String statusSpanId) throws IOException {
+        writer.startElement("div", null);
+
+        writer.writeAttribute("className", "status", null);
+        writer.writeAttribute("style", "float:right;", null);
+        writer.writeAttribute("id", statusSpanId, null);
+        writer.endElement("div");
+    }
+
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererTextarea.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererTextarea.java?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererTextarea.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererTextarea.java Wed May  3 14:24:53 2006
@@ -0,0 +1,282 @@
+package org.apache.myfaces.custom.pagelet;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
+import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+
+public class SubrendererTextarea extends BasePageletRenderer {
+    public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
+    	encodeEndTextarea(facesContext, uiComponent);
+    }
+    
+    /**
+     * encode end for the basic text area functionality
+     * @param facesContext
+     * @param uiComponent
+     * @throws IOException
+     */
+    protected void encodeEndTextarea(FacesContext facesContext, UIComponent uiComponent) throws IOException {
+        RendererUtils.checkParamValidity(facesContext, uiComponent, Pagelet.class);
+
+        if (!uiComponent.isRendered())
+            return;
+
+        Pagelet spchk = (Pagelet) uiComponent;
+        encodeJavascript(facesContext, uiComponent);
+
+        ResponseWriter writer = facesContext.getResponseWriter();
+
+        String uniqueId = calcUniqueId(uiComponent, facesContext);
+
+        writeTextArea(facesContext, spchk, writer, uniqueId, false);
+
+        //if (spchk.getControlMode().equals(spchk.COMTROL_MODE_PAGELET_RAWTEXT)) {
+        //    writeRawTextDialog(facesContext, spchk, writer);
+        // }
+        // end control panel
+    }
+
+    
+        
+    /**
+     * text area encoding
+     *
+     * @param context
+     * @param component
+     */
+    public void encodeJavascript(FacesContext context, UIComponent component) throws IOException {
+        // AddResource takes care to add only one reference to the same script
+
+        Pagelet spchk = (Pagelet) component;
+
+        String javascriptLocation = (String) component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
+
+        String styleLocation = (String) component.getAttributes().get(JSFAttr.STYLE_LOCATION);
+
+        AddResource addResource = AddResourceFactory.getInstance(context);
+
+        /* javascriptLocation = "/scripts/"; */
+        if (javascriptLocation != null) {
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "cpaint2.inc.js");
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "spell_checker.js");
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "utils.js");
+
+        } else {
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, Pagelet.class, "cpaint2.inc.js");
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, Pagelet.class, "spell_checker.js");
+            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, Pagelet.class, "utils.js");
+        }
+
+        /*if (spchk.getControlMode().equals(Pagelet.COMTROL_MODE_PAGELET_RAWTEXT)) {
+            encodeJavascriptPagelet(context, component); //in raw text we need the pagelet dojo includes as well
+
+            //since we recycle some of the mechanisms
+        }
+        */
+        if (styleLocation == null)
+            addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, Pagelet.class, "spell_checker.css");
+        else
+            addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, styleLocation + "spell_checker.css");
+
+        //TODO<< Add the dialog resource definition css include
+
+    }
+    
+    
+    
+    protected void writeTextArea(FacesContext facesContext, Pagelet spchk, ResponseWriter writer, String uniqueId,
+            boolean asDialog) throws IOException {
+        String divId      = uniqueId + DIV_ID_SUFFIX;
+        String varName    = uniqueId + TEXTBOX_ID_SUFFIX;
+        String textAreaId = uniqueId + TEXT_AREA_SUFFIX;
+        String editDivId  = uniqueId + EDIT_DIV_SUFFIX;
+        String formName   = uniqueId + FORM_SUFFIX;
+
+        String methodBinding = spchk.getSpellchecker().getExpressionString();
+
+
+        if (spchk.isDisplayValueOnly()) {
+            writer.startElement("div", null);
+            HtmlRendererUtils.writeIdIfNecessary(writer, spchk, facesContext);
+
+            String style = "width:" + spchk.getWidth() + "px;" + "heigth:" + spchk.getHeight() + "px;" + spchk.getDisplayValueOnlyStyle();
+
+            writer.writeAttribute("style", style, null);
+
+            if (spchk.getDisplayValueOnlyStyleClass() != null)
+                writer.writeAttribute("class", spchk.getDisplayValueOnlyStyleClass(), null);
+                //TODO add the dialog handling here
+
+            String strValue = RendererUtils.getStringValue(facesContext, spchk);
+            writer.writeText(strValue, JSFAttr.VALUE_ATTR);
+            writer.endElement("div");
+
+            return;
+        }
+
+        // control panel
+
+        // positioning table
+        startWriterPositioningTable(writer);
+        startContentColum(writer);
+
+        {
+            startControlPanel(writer, divId);
+
+            // textarea
+            writeTextarea(writer, textAreaId, spchk, formName);
+
+            // edit div
+            writeEditDiv(writer, spchk, editDivId);
+            endControlPanel(writer);
+        }
+
+        endContentColum(writer);
+
+        writeActionLinks2(facesContext, spchk, writer, uniqueId, asDialog);
+    }
+    
+    protected void writeActionLinks2(FacesContext facesContext, Pagelet spchk, ResponseWriter writer, String uniqueId,
+            boolean asDialog) throws IOException {
+        String divId      = uniqueId + DIV_ID_SUFFIX;
+        String varName    = uniqueId + TEXTBOX_ID_SUFFIX;
+        String textAreaId = uniqueId + TEXT_AREA_SUFFIX;
+        String formName   = uniqueId + FORM_SUFFIX;
+
+
+        String actionSpanId = getActionSpanId(uniqueId);
+        String resizeSpanId = getResizeId(uniqueId);
+        String statusSpanId = getStatusSpanId(uniqueId);
+
+        String  zoomSpanId    = getZoomId(uniqueId);
+        boolean writeLinks    = (spchk.getLinkSpellchecker() != null) && (spchk.getLinkResume() != null) && !spchk.isDisabled() && !spchk.isReadonly();
+        boolean writeResizer  = (spchk.getLinkResize() != null) && (spchk.getLinkDownsize() != null) && !spchk.isDisabled();
+        boolean writeZoom     = (spchk.getLinkZoom() != null) && !spchk.isDisabled() && !asDialog;
+        String  methodBinding = spchk.getSpellchecker().getExpressionString();
+
+        startPositionColumn(writer);
+
+        {
+
+            // resizer
+            writer.startElement("div", null);
+
+            if (!spchk.getControlMode().equals(Pagelet.COMTROL_MODE_PAGELET_RAWTEXT)) {
+
+                if (!asDialog)
+                    writeActionLinks(writeLinks, writer, varName, facesContext, spchk, resizeSpanId);
+
+                writeBR(writer);
+
+                writeResizerLinks(writer, facesContext, spchk, textAreaId, resizeSpanId, zoomSpanId, writeResizer, writeZoom);
+
+                writeBR(writer);
+
+                if (!asDialog)
+                    writeStatusSpan(writer, statusSpanId);
+            } else {
+
+                if (!asDialog)
+                    writeResizerLinks(writer, facesContext, spchk, textAreaId, resizeSpanId, zoomSpanId, writeResizer, writeZoom);
+
+            }
+
+            writer.endElement("div");
+        }
+
+        endPositionColumn(writer);
+        endWriterPositioningTable(writer);
+
+
+        // script
+        if (!asDialog) {
+            writeScript(writer, spchk, facesContext, varName, spchk, divId, formName, actionSpanId, statusSpanId, textAreaId, methodBinding,
+                writeLinks);
+        }
+    }
+    
+
+    protected void writeActionLinks(boolean writeLinks, ResponseWriter writer, String varName, FacesContext facesContext,
+            Pagelet spchk, String resizerId) throws IOException {
+
+        if (writeLinks) {
+            String uniqueId      = calcUniqueId(spchk, facesContext);
+            String linkSpellchId = uniqueId + "spellchk"; // TODO unique
+            String linkResumeId  = uniqueId + "resume"; // TODO unique
+            writer.startElement("div", null);
+            writer.writeAttribute("id", linkSpellchId, null);
+            writer.writeAttribute("onclick", "displayInline('" + linkResumeId + "');setCurrentObject(" + varName + ");" + varName + ".spellCheck();displayNone('" + linkSpellchId + "');displayNone('" + resizerId + "');", null);
+            RendererUtils.renderChild(facesContext, spchk.getLinkSpellchecker());
+            writer.endElement("div");
+            writer.startElement("div", null);
+            writer.writeAttribute("id", linkResumeId, null);
+            writer.writeAttribute("style", "display:none", null);
+            writer.writeAttribute("onclick", "displayInline('" + linkSpellchId + "');setCurrentObject(" + varName + ");" + varName + ".resumeEditing();displayNone('" + linkResumeId + "');displayInline('" + resizerId + "');", null);
+            RendererUtils.renderChild(facesContext, spchk.getLinkResume());
+            writer.endElement("div");
+        }
+    }
+    
+    protected void writeScript(ResponseWriter writer, UIComponent uiComponent, FacesContext facesContext, String varName,
+            Pagelet spchk, String divId, String formName, String actionSpanId, String statusSpanId, String textAreaId,
+            String methodBinding, boolean writeLinks) throws IOException {
+        writer.startElement(HTML.SCRIPT_ELEM, uiComponent);
+        writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
+
+        /*
+         * @param varName - the name of the variable that the object is assigned
+         * to (must be unique and the same as the variable) @param width - the
+         * width of the spell checker textarea @param height - the height of the
+         * spell checker textarea @param spellUrl - the url of the
+         * spell_checker.php code @param divId - the id of the div that the
+         * spell checker is contained in (must be unique) @param name - the name
+         * of the textarea form element @param actionSpanId - the id of the
+         * action span @param statusSpanId - the id of the status span @param id -
+         * the id of the spell checker textarea (must be unique) @param
+         * spellcheckermb Methodbinding // MODIFIED LIBRARY FOR THIS FEATURE
+         */
+
+        String       strValue = RendererUtils.getStringValue(facesContext, uiComponent);
+        StringBuffer script   = new StringBuffer();
+
+        script.append("var ").append(varName).append(" = new ajaxSpell('").append(varName).append("',").append(asString(spchk.getWidth())).append(",").append(asString(spchk.getHeight())).append(",'").append(getSpellcheckServletPath(facesContext)).append("', '").append(divId).append("', '").append(formName).append("', '").append(actionSpanId).append("', '").append(statusSpanId).append("', '").append(textAreaId).append("', '").append(methodBinding).append("',").append(asString(spchk.getTextSpellcheck(), (!writeLinks) ? "Check Spelling &amp; Preview" : null)).append(",").append(asString(spchk.getTextResume(), (!writeLinks) ? "Resume Editing" : null)).append(",").append(asString(spchk.getTextWorking(), "Working ...")).append(",").append(asString(spchk.getTextNoMisspellings(), "No Misspellings Found")).append(",").append(asString(spchk.getTextChecking(), "Checking ...")).append(");\n");
+        script.append(varName).append(".objToCheck.value=unescape('").append(StringEscapeUtils.escapeJavaScript(strValue)).append("');\n"); // TODO
+
+        // encode
+        // value
+        writer.writeText(script.toString(), null);
+        writer.endElement(HTML.SCRIPT_ELEM);
+    }
+
+    protected void writeTextarea(ResponseWriter writer, String textAreaId, Pagelet spchk, String formName) throws IOException {
+        writer.startElement(HTML.TEXTAREA_ELEM, null);
+        writer.writeAttribute(HTML.CLASS_ATTR, "resizable", null);
+        writer.writeAttribute(HTML.ID_ATTR, textAreaId, null);
+        writer.writeAttribute(HTML.STYLE_ATTR, "width:" + spchk.getWidth() + "px;height:" + spchk.getHeight() + "px", null);
+        writer.writeAttribute("name", textAreaId, null); // TODO:possible
+
+        // bug, have to
+        // recheck that with
+        // tom dual name
+        writer.writeAttribute("name", formName, null);
+
+        if (spchk.isDisabled())
+            writer.writeAttribute(HTML.DISABLED_ATTR, spchk.isDisabled() + "", null);
+
+        if (spchk.isReadonly())
+            writer.writeAttribute(HTML.READONLY_ATTR, spchk.isReadonly() + "", null);
+
+        writer.endElement(HTML.TEXTAREA_ELEM);
+    }
+
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Text.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Text.java?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Text.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Text.java Wed May  3 14:24:53 2006
@@ -0,0 +1,38 @@
+package org.apache.myfaces.custom.pagelet;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author Thomas Spiegl
+ */
+public class Text {
+
+    private List _words;
+
+    Text(List words) {
+        _words = words;
+    }
+
+    Text(Word word) {
+        _words = new ArrayList(1);
+        _words.add(word);
+    }
+
+    /**
+     * @return {@link Word}
+     */
+    public Collection getWords() {
+        List list = new ArrayList();
+        for (int i = 0; i < _words.size(); i++)
+        {
+            Word word = (Word) _words.get(i);
+            if (word.checkSpelling)
+            {
+                list.add(word);
+            }
+        }
+        return list;
+    }
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Word.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Word.java?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Word.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Word.java Wed May  3 14:24:53 2006
@@ -0,0 +1,54 @@
+package org.apache.myfaces.custom.pagelet;
+
+/**
+ * @author Thomas Spiegl
+ */
+public class Word {
+    boolean          checkSpelling;
+    int              _originalPosition = 0;
+    private String[] _alternatives;
+    private boolean  _invalid;
+    private String   _value;
+
+    Word(String value, boolean checkSpelling, int originalPosition) {
+        _value                = value;
+        this.checkSpelling    = checkSpelling;
+        this._originalPosition = originalPosition;
+    }
+
+    public String[] getAlternatives() {
+        return _alternatives;
+    }
+
+    public int getOriginalPosition() {
+        return _originalPosition;
+    }
+
+    public String getValue() {
+        return _value;
+    }
+
+    public boolean isInvalid() {
+        return _invalid;
+    }
+
+    public void setAlternatives(String[] alternatives) {
+
+        if (!checkSpelling)
+            throw new IllegalArgumentException("checkSpelling if false");
+
+        _alternatives = alternatives;
+    }
+
+    public void setInvalid(boolean invalid) {
+
+        if (!checkSpelling)
+            throw new IllegalArgumentException("checkSpelling if false");
+
+        _invalid = invalid;
+    }
+
+    public void setOriginalPosition(int originalPosition) {
+        this._originalPosition = originalPosition;
+    }
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/MyFacesHiddenRichText.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/MyFacesHiddenRichText.js?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/MyFacesHiddenRichText.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/MyFacesHiddenRichText.js Wed May  3 14:24:53 2006
@@ -0,0 +1,229 @@
+dojo.provide("org.apache.myfaces.pagelet.MyFacesHiddenRichText");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.dom");
+dojo.require("dojo.html");
+dojo.require("dojo.event.*");
+dojo.require("dojo.style");
+dojo.require("dojo.widget.HtmlRichText");
+
+/**
+* a helper rich text inliner based on a original hidden field
+* this is handy for controls which do not want to be based on
+* text areas for form value traversal
+* TODO move this into its own package
+* once the dojo allows packaged components
+*/
+org.apache.myfaces.pagelet.MyFacesHiddenRichText = function() {
+	dojo.widget.HtmlRichText.call(this);	
+	dojo.debug("hiddenrichie");
+	this.widgetType = "MyFacesHiddenRichText";
+	this.changeNotified = false;
+};
+
+/**
+* lets kick in the inheritance
+*/
+dojo.inherits(org.apache.myfaces.pagelet.MyFacesHiddenRichText, dojo.widget.HtmlRichText);
+dojo.widget.tags.addParseTreeHandler("dojo:myfaceshiddenrichtext");
+
+
+dojo.lang.extend(org.apache.myfaces.pagelet.MyFacesHiddenRichText, {
+	
+	/**
+	 * Transforms the node referenced in this.domNode into a rich text editing
+	 * node. This can result in the creation and replacement with an <iframe> if
+	 * designMode is used, an <object> and active-x component if inside of IE or
+	 * a reguler element if contentEditable is available.
+	 */
+	open: function (element) {
+		var html = "";
+		dojo.event.topic.publish("dojo.widget.RichText::open", this);
+
+		if (!this.isClosed) { this.close(); }
+		this._content = "";
+		if (arguments.length == 1) { this.domNode = element; } // else unchanged
+		/*todo reduce the code duplication by figuring out on how 
+		to call the super methods*/
+		if (this.domNode.nodeName == "INPUT" || this.domNode.nodeName == "TEXTAREA") {
+			this.textarea = this.domNode;
+			this.domNode = document.createElement("div");
+			with(this.textarea.style){
+				display = "block";
+				position = "absolute";
+				width = "1px";
+				height = "1px";
+				border = margin = padding = "0px";
+				visiblity = "hidden";
+			}
+			dojo.dom.insertBefore(this.domNode, this.textarea);
+			//this.domNode.innerHTML = html;
+			
+			if(this.textarea.form){
+				dojo.event.connect(this.textarea.form, "onsubmit", 
+					dojo.lang.hitch(this, function(){
+						this.textarea.value = this.getEditorContent();
+					})
+				);
+			}
+			/*we add a helper to the textarea so that we can keep em in sync*/
+			this.textarea.setEditorContent = dojo.lang.hitch(this.textarea, function(val) {
+				this.setEditorContent(val);
+			});			
+			/*
+			we also add a geteditorcontent function so that we are in sync
+			also at the get stage
+			*/
+			this.textarea.getEditorContent = dojo.lang.hitch(this.textarea, function() {
+				var val = this.getEditorContent();
+				this.textarea.value = val;
+				return val;
+			});			
+			
+			
+			
+			// dojo plucks our original domNode from the document so we need
+			// to go back and put ourselves back in
+			var editor = this;
+			dojo.event.connect(this, "postCreate", function (){
+				dojo.dom.insertAfter(editor.textarea, editor.domNode);
+			});
+			html = this.textarea.value;
+		} else {
+			html = this.domNode.innerHTML;
+		}
+				
+		this._oldHeight = dojo.style.getContentHeight(this.domNode);
+		this._oldWidth = dojo.style.getContentWidth(this.domNode);
+		
+		this.savedContent = document.createElement("div");
+		while (this.domNode.hasChildNodes()) {
+			this.savedContent.appendChild(this.domNode.firstChild);
+		}
+		
+		// If we're a list item we have to put in a blank line to force the
+		// bullet to nicely align at the top of text
+		if (this.domNode.nodeName == "LI") { this.domNode.innerHTML = " <br>"; }
+				
+		if (this.saveName != "") {
+			var saveTextarea = document.getElementById("dojo.widget.RichText.savedContent");
+			if (saveTextarea.value != "") {
+				var datas = saveTextarea.value.split(this._SEPARATOR);
+				for (var i = 0; i < datas.length; i++) {
+					var data = datas[i].split(":");
+					if (data[0] == this.saveName) {
+						html = data[1];
+						datas.splice(i, 1);
+						break;
+					}
+				}				
+			}
+			this.connect(window, "onunload", "_saveContent");
+		}
+
+		// Safari's selections go all out of whack if we do it inline,
+		// so for now IE is our only hero
+		//if (typeof document.body.contentEditable != "undefined") {
+		if (this.useActiveX && dojo.render.html.ie) { // active-x
+			this._drawObject(html);
+		} else if (dojo.render.html.ie) { // contentEditable, easy
+			this.editNode = document.createElement("div");
+			with (this.editNode) {
+				contentEditable = true;
+				innerHTML = html;
+				style.height = this.minHeight;
+			}
+			this.domNode.appendChild(this.editNode);
+			
+			var events = ["onBlur", "onFocus", "onKeyPress",
+				"onKeyDown", "onKeyUp", "onClick"];
+			for (var i = 0; i < events.length; i++) {
+				this.connect(this.editNode, events[i].toLowerCase(), events[i]);
+			}
+		
+			this.window = window;
+			this.document = document;
+			
+			this.onLoad();
+		} else { // designMode in iframe
+			this._drawIframe(html);
+		}
+
+		// TODO: this is a guess at the default line-height, kinda works
+		if (this.domNode.nodeName == "LI") { this.domNode.lastChild.style.marginTop = "-1.2em"; }
+		dojo.html.addClass(this.domNode, "RichTextEditable");
+		
+		this.isClosed = false;
+		if(dojo.render.html.ie)
+			dojo.event.connect(this.editNode, "onkeydown",this, "keydown"); 
+	
+	
+	}, 
+	
+	
+	setEditorContent: function(val){
+		var ec = val;
+		dojo.lang.forEach(this.contentFilters, function(ef){
+			ec = ef(ec);
+		});
+		
+		try{
+			if(this._content.length > 0)
+				this._content = ec;
+			else
+				this.editNode.innerHTML = ec;
+			this.textarea.value = this.getEditorContent();
+		}catch(e){ /* squelch */ }
+	},
+	
+	/**
+	* some key shifting here
+	* due to demands by third parties
+	* we have to shift the default ie behavior a little bit
+	* in the enter key areas
+	*/
+	keydown: function(evt) {
+		
+		if(!this.changeNotified && typeof(myfaces_stateChange_notificationFields)!="undefined" && myfaces_stateChange_notificationFields != null) {
+		  //first trigger the notifier we have a change
+			var notifierArray = myfaces_stateChange_notificationFields;
+		  	this.changeNotified = true;
+		  	if(notifierArray != null) {
+		  		for(var notifierField in notifierArray) {
+		  		
+		  			if(notifierArray[notifierField] != null) {
+			  			notifierField = dojo.byId(notifierArray[notifierField]);
+			  			notifierField.value = "true";
+			  			
+			  		}
+		  		}
+		  	}
+		}	
+		
+
+		//enter now is enter
+		if((!evt.ctrlKey) && evt.keyCode == 13) {
+			//This is a fix for the input key handler in ie
+			//so that it behaves in a sane way regarding line breaks
+			evt.preventDefault();
+			//since this has to work on ie only
+			if (document.selection) {
+            	var range = document.selection.createRange();
+            	if (this.editNode.parentElement.contains(range.parentElement())) {
+                	range.pasteHTML("<br>");
+                	range.select();
+            	} 	
+            }
+		} else if(evt.keyCode == 13) {//ctrl enter now is paragraph, I hate IE
+			evt.preventDefault();
+			//since this has to work on ie only
+			if (document.selection) {
+            	var range = document.selection.createRange();
+            	if (this.editNode.parentElement.contains(range.parentElement())) {
+                	range.pasteHTML("<p></p>");
+                	range.select();
+            	} 	
+            }
+		}
+	}
+});
\ No newline at end of file

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/__package__.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/__package__.js?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/__package__.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/__package__.js Wed May  3 14:24:53 2006
@@ -0,0 +1,4 @@
+dojo.provide("org.apache.myfaces.pagelet");
+dojo.widget.manager.registerWidgetPackage("org.apache.myfaces.pagelet"); 
+
+

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/cpaint2.inc.compressed.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/cpaint2.inc.compressed.js?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/cpaint2.inc.compressed.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/cpaint2.inc.compressed.js Wed May  3 14:24:53 2006
@@ -0,0 +1,90 @@
+/**
+* CPAINT - Cross-Platform Asynchronous INterface Toolkit
+*
+* http://cpaint.sourceforge.net
+* 
+* released under the terms of the LGPL
+* see http://www.fsf.org/licensing/licenses/lgpl.txt for details
+*
+* @package      CPAINT
+* @access       public
+* @copyright    Copyright (c) 2005 Paul Sullivan, Dominique Stender - http://cpaint.sourceforge.net
+* @author       Paul Sullivan <wi...@gmail.com>
+* @author       Dominique Stender <ds...@st-webdevelopment.de>
+* @version      2.0.1
+*/
+function cpaint(){var config=new Array();config['debugging']=0;config['proxy_url']='';config['transfer_mode']='GET';config['async']=true;config['response_type']='OBJECT';config['persistent_connection']=false;config['use_cpaint_api']=true;var stack_count=0;this.capable=test_ajax_capability();this.set_debug=function(){if(typeof arguments[0]=='boolean'){if(arguments[0]===true){config['debugging']=1;}else{config['debugging']=0;}}else if(typeof arguments[0]=='number'){config['debugging']=Math.round(arguments[0]);}}
+this.set_proxy_url=function(){if(typeof arguments[0]=='string'){config['proxy_url']=arguments[0];}}
+this.set_transfer_mode=function(){if(arguments[0].toUpperCase()=='GET'||arguments[0].toUpperCase()=='POST'){config['transfer_mode']=arguments[0].toUpperCase();}}
+this.set_async=function(){if(typeof arguments[0]=='boolean'){config['async']=arguments[0];}}
+this.set_response_type=function(){if(arguments[0].toUpperCase()=='TEXT'||arguments[0].toUpperCase()=='XML'||arguments[0].toUpperCase()=='OBJECT'){config['response_type']=arguments[0].toUpperCase();}}
+this.set_persistent_connection=function(){if(typeof arguments[0]=='boolean'){config['persistent_connection']=arguments[0];}}
+this.set_use_cpaint_api=function(){if(typeof arguments[0]=='boolean'){config['use_cpaint_api']=arguments[0];}}
+function test_ajax_capability(){var cpc=new cpaint_call(0);return cpc.test_ajax_capability();}
+this.call=function(){var use_stack=-1;if(config['persistent_connection']==true&&typeof __cpaint_stack[0]=='object'){switch(__cpaint_stack[0].get_http_state()){case-1:use_stack=0;debug('no XMLHttpObject object to re-use for persistence, creating new one later',2);break;case 4:use_stack=0
+debug('re-using the persistent connection',2);break;default:debug('the persistent connection is in use - skipping this request',2);}}else if(config['persistent_connection']==true){use_stack=0;__cpaint_stack[use_stack]=new cpaint_call(use_stack);debug('no cpaint_call object available for re-use, created new one',2);}else{use_stack=stack_count;__cpaint_stack[use_stack]=new cpaint_call(use_stack);debug('no cpaint_call object created new one',2);}
+if(use_stack!=-1){__cpaint_stack[use_stack].set_debug(config['debugging']);__cpaint_stack[use_stack].set_proxy_url(config['proxy_url']);__cpaint_stack[use_stack].set_transfer_mode(config['transfer_mode']);__cpaint_stack[use_stack].set_async(config['async']);__cpaint_stack[use_stack].set_response_type(config['response_type']);__cpaint_stack[use_stack].set_persistent_connection(config['persistent_connection']);__cpaint_stack[use_stack].set_use_cpaint_api(config['use_cpaint_api']);__cpaint_stack[use_stack].set_client_callback(arguments[2]);if(config['proxy_url']!=''){__cpaint_stack[use_stack].call_proxy(arguments);}else{__cpaint_stack[use_stack].call_direct(arguments);}
+stack_count++;debug('stack size: '+__cpaint_stack.length,2);}}
+var debug=function(message,debug_level){if(config['debugging']>=debug_level){alert('[CPAINT Debug] '+message);}}}
+var __cpaint_stack=new Array();var __cpaint_transformer=new cpaint_transformer();function cpaint_call(){var debugging=false;var httpobj=false;var proxy_url='';var transfer_mode='GET';var async=true;var response_type='OBJECT';var persistent_connection=false;var use_cpaint_api=true;var client_callback;var stack_id=arguments[0];this.set_debug=function(){if(typeof arguments[0]=='number'){debugging=Math.round(arguments[0]);}}
+this.set_proxy_url=function(){if(typeof arguments[0]=='string'){proxy_url=arguments[0];}}
+this.set_transfer_mode=function(){if(arguments[0].toUpperCase()=='GET'||arguments[0].toUpperCase()=='POST'){transfer_mode=arguments[0].toUpperCase();}}
+this.set_async=function(){if(typeof arguments[0]=='boolean'){async=arguments[0];}}
+this.set_response_type=function(){if(arguments[0].toUpperCase()=='TEXT'||arguments[0].toUpperCase()=='XML'||arguments[0].toUpperCase()=='OBJECT'){response_type=arguments[0].toUpperCase();}}
+this.set_persistent_connection=function(){if(typeof arguments[0]=='boolean'){persistent_connection=arguments[0];}}
+this.set_use_cpaint_api=function(){if(typeof arguments[0]=='boolean'){use_cpaint_api=arguments[0];}}
+this.set_client_callback=function(){if(typeof arguments[0]=='function'){client_callback=arguments[0];}}
+this.get_http_state=function(){var return_value=-1;if(typeof httpobj=='object'){return_value=httpobj.readyState;}
+return return_value;}
+this.call_direct=function(call_arguments){var url=call_arguments[0];var remote_method=call_arguments[1];var querystring='';var i=0;if(url=='SELF'){url=document.location.href;}
+if(use_cpaint_api==true){for(i=3;i<call_arguments.length;i++){querystring+='&cpaint_argument[]='+encodeURIComponent(call_arguments[i]);}
+querystring+='&cpaint_response_type='+response_type;if(transfer_mode=='GET'){url=url+'?cpaint_function='+remote_method+querystring;}else{querystring='cpaint_function='+remote_method+querystring;}}else{for(i=3;i<call_arguments.length;i++){if(i==3){querystring+=encodeURIComponent(call_arguments[i]);}else{querystring+='&'+encodeURIComponent(call_arguments[i]);}}
+if(transfer_mode=='GET'){url=url+querystring;}}
+get_connection_object();debug('opening connection to "'+url+'"',1);httpobj.open(transfer_mode,url,async);if(transfer_mode=="POST"){try{httpobj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}catch(cp_err){alert('ERROR! POST cannot be completed due to incompatible browser.  Use GET as your request method.');}}
+httpobj.onreadystatechange=callback;if(transfer_mode=='GET'){httpobj.send(null);}else{debug('sending query: '+querystring,1);httpobj.send(querystring);}
+if(async==false){callback();}}
+this.call_proxy=function(call_arguments){var proxyscript=proxy_url;var url=call_arguments[0];var remote_method=call_arguments[1];var querystring='';var i=0;var querystring_argument_prefix='cpaint_argument[]=';if(use_cpaint_api==false){querystring_argument_prefix='';}
+for(i=3;i<call_arguments.length;i++){querystring+=encodeURIComponent(querystring_argument_prefix+call_arguments[i]+'&');}
+if(use_cpaint_api==true){querystring+=encodeURIComponent('&cpaint_function='+remote_method);querystring+=encodeURIComponent('&cpaint_responsetype='+response_type);}
+if(transfer_mode=='GET'){proxyscript+='?cpaint_remote_url='+encodeURIComponent(url)
++'&cpaint_remote_query='+querystring
++'&cpaint_remote_method='+transfer_mode
++'&cpaint_response_type='+response_type;}else{querystring='cpaint_remote_url='+encodeURIComponent(url)
++'&cpaint_remote_query='+querystring
++'&cpaint_remote_method='+transfer_mode
++'&cpaint_response_type='+response_type;}
+get_connection_object();debug('opening connection to proxy "'+proxyscript+'"',1);httpobj.open(transfer_mode,proxyscript,async);if(transfer_mode=="POST"){try{httpobj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}catch(cp_err){alert('[CPAINT Error] POST cannot be completed due to incompatible browser.  Use GET as your request method.');}}
+httpobj.onreadystatechange=callback;if(transfer_mode=='GET'){httpobj.send(null);}else{debug('sending query: '+querystring,1);httpobj.send(querystring);}
+if(async==false){callback();}}
+this.test_ajax_capability=function(){return get_connection_object();}
+var get_connection_object=function(){var return_value=false;var new_connection=false;if(persistent_connection==false){debug('Using new connection object',1);new_connection=true;}else{debug('Using shared connection object.',1);if(typeof httpobj!='object'){debug('Getting new persistent connection object.',1);new_connection=true;}}
+if(new_connection==true){try{httpobj=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{httpobj=new ActiveXObject('Microsoft.XMLHTTP');}catch(oc){httpobj=null;}}
+if(!httpobj&&typeof XMLHttpRequest!='undefined'){httpobj=new XMLHttpRequest();}
+if(!httpobj){alert('[CPAINT Error] Could not create connection object');}else{return_value=true;}}
+if(httpobj.readyState!=4){httpobj.abort();}
+return return_value;}
+var callback=function(){var response=null;if(httpobj.readyState==4){debug(httpobj.responseText,1);switch(response_type){case'XML':response=__cpaint_transformer.xml_conversion(httpobj.responseXML);break;case'OBJECT':response=__cpaint_transformer.object_conversion(httpobj.responseXML);break;case'TEXT':response=__cpaint_transformer.text_conversion(httpobj.responseText);break;default:alert('[CPAINT Error] invalid response type \''+response_type+'\'');}
+if(response!=null&&typeof client_callback=='function'){client_callback(response,httpobj.responseText);}
+remove_from_stack();}}
+var remove_from_stack=function(){if(typeof stack_id=='number'&&__cpaint_stack[stack_id]&&persistent_connection==false){__cpaint_stack[stack_id]=null;}}
+var debug=function(message,debug_level){if(debugging>=debug_level){alert('[CPAINT Debug] '+message);}}}
+function cpaint_transformer(){this.object_conversion=function(xml_document){var return_value=new cpaint_result_object();var i=0;var firstNodeName='';if(typeof xml_document=='object'&&xml_document!=null){for(i=0;i<xml_document.childNodes.length;i++){if(xml_document.childNodes[i].nodeType==1){firstNodeName=xml_document.childNodes[i].nodeName;break;}}
+var ajax_response=xml_document.getElementsByTagName(firstNodeName);return_value[firstNodeName]=new Array();for(i=0;i<ajax_response.length;i++){var tmp_node=create_object_structure(ajax_response[i]);tmp_node.id=ajax_response[i].getAttribute('id')
+return_value[firstNodeName].push(tmp_node);}}else{alert('[CPAINT Error] received invalid XML response');}
+return return_value;}
+this.xml_conversion=function(xml_document){return xml_document;}
+this.text_conversion=function(text){return decode(text);}
+var create_object_structure=function(stream){var return_value=new cpaint_result_object();var node_name='';var i=0;var attrib=0;if(stream.hasChildNodes()==true){for(i=0;i<stream.childNodes.length;i++){node_name=decode(stream.childNodes[i].nodeName);node_name=node_name.replace(/[^a-zA-Z0-9]*/g,'');if(typeof return_value[node_name]!='object'){return_value[node_name]=new Array();}
+if(stream.childNodes[i].nodeType==1){var tmp_node=create_object_structure(stream.childNodes[i]);for(attrib=0;attrib<stream.childNodes[i].attributes.length;attrib++){tmp_node.set_attribute(decode(stream.childNodes[i].attributes[attrib].nodeName),decode(stream.childNodes[i].attributes[attrib].nodeValue));}
+return_value[node_name].push(tmp_node);}else if(stream.childNodes[i].nodeType==3){return_value.data=decode(stream.firstChild.data);}}}
+return return_value;}
+var decode=function(rawtext){var plaintext='';var i=0;var c1=0;var c2=0;var c3=0;var u=0;var t=0;while(i<rawtext.length){if(rawtext.charAt(i)=='\\'&&rawtext.charAt(i+1)=='u'){u=0;for(j=2;j<6;j+=1){t=parseInt(rawtext.charAt(i+j),16);if(!isFinite(t)){break;}
+u=u*16+t;}
+plaintext+=String.fromCharCode(u);i+=6;}else{plaintext+=rawtext.charAt(i);i++;}}
+if(plaintext!==''&&!isNaN(plaintext)&&isFinite(plaintext)){plaintext=Number(plaintext);}
+return plaintext;}}
+function cpaint_result_object(){this.id=0;this.data=0;var __attributes=new Array();this.find_item_by_id=function(){var return_value=null;var type=arguments[0];var id=arguments[1];var i=0;if(this[type]){for(i=0;i<this[type].length;i++){if(this[type][i].get_attribute('id')==id){return_value=this[type][i];break;}}}
+return return_value;}
+this.get_attribute=function(){var return_value=null;var id=arguments[0];if(typeof __attributes[id]!='undefined'){return_value=__attributes[id];}
+return return_value;}
+this.set_attribute=function(){__attributes[arguments[0]]=arguments[1];}}
\ No newline at end of file