myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r399437 [1/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...
Date Wed, 03 May 2006 21:24:58 GMT
Author: werpu
Date: Wed May  3 14:24:53 2006
New Revision: 399437

URL: http://svn.apache.org/viewcvs?rev=399437&view=rev
Log:
added the initial pagelet codebase

Added:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxInputSpellcheck.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxSpellCheckHandler.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxSpellcheckerServlet.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/BasePageletRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/HTMLDecoder.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Pagelet.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/PageletRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/PageletTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererPagelet.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererPageletRawText.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/SubrendererTextarea.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Text.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Word.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/MyFacesHiddenRichText.js
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/__package__.js
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/cpaint2.inc.compressed.js
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/cpaint2.inc.js
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/css/
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/css/pagelet.css
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/img/
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/img/CANCEL_0.gif   (with props)
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/img/CLEAR_0.gif   (with props)
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/img/OK_0.gif   (with props)
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/img/RESUME_0.gif   (with props)
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/img/SPELLCHECK_0.gif   (with props)
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/myfacesdlg.js
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/pagelet.js
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/progressor.js
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/spell_checker.css
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/spell_checker.js
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/pagelet/resource/utils.js

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxInputSpellcheck.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxInputSpellcheck.java?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxInputSpellcheck.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxInputSpellcheck.java Wed May  3 14:24:53 2006
@@ -0,0 +1,20 @@
+package org.apache.myfaces.custom.pagelet;
+
+
+/**
+ * @author Thomas Spiegl
+ * 
+ * compatibility class for a customer
+ * project
+ * all the needed stuff has been moved
+ * into pagelet
+ * for the myfaces checkin
+ *
+ */
+public class AjaxInputSpellcheck extends Pagelet  {
+
+	public AjaxInputSpellcheck() {
+		super();
+	}
+
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxSpellCheckHandler.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxSpellCheckHandler.java?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxSpellCheckHandler.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxSpellCheckHandler.java Wed May  3 14:24:53 2006
@@ -0,0 +1,392 @@
+package org.apache.myfaces.custom.pagelet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.webapp.UIComponentTag;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.myfaces.shared_tomahawk.renderkit.html.util.*;
+
+/**
+ * @author Thomas Spiegl
+ */
+public class AjaxSpellCheckHandler {
+
+    private static final String  SPCK2_PARAM_NAME      = "spck[]";
+    private static final int     FLAGS                 = Pattern.CASE_INSENSITIVE | Pattern.DOTALL;
+    private static final Pattern SPAN                  = Pattern.compile("<span(.*?)>(.*?)</span>", FLAGS);
+    private static final Pattern URL_PATTERN           = Pattern.compile("(https?|ftp|mailto)://[a-zA-Z0-9\\.@]+\\.[a-zA-Z]{2,3}",
+            Pattern.DOTALL);
+    private static final Pattern EMAIL_PATTERN         = Pattern.compile("[a-zA-Z0-9_\\.]+@[a-zA-Z0-9_\\.]+\\.[a-zA-Z]{2,3}",
+            Pattern.DOTALL);
+    private static final Pattern WORDS_PATTERN         = Pattern.compile("[a-zxA-Z]+", Pattern.DOTALL);
+    private static final Pattern ENUMERATION_PATTERN   = Pattern.compile("^\\s*[a-zA-Z0-9\\.]+\\)", Pattern.MULTILINE);
+    private static final Pattern XHMTL_PATTERN         = Pattern.compile("(<[^>]+>)|(\\&[A-Za-z\\#0-9]+\\;)", Pattern.MULTILINE);
+    private static final String  PARAM_NAME            = "cpaint_argument[]";
+
+    public static void main(String[] argv) {
+        System.out.println(("<li><a href='#' id=':evt_target_id_corrid_" + 1 + "'>:correctionWord</a></li>").replaceAll("(\\:evt_target_id)", "boogaqloo"));
+    }
+
+    public void handleAjaxRequest(FacesContext facesContext) throws ServletException, IOException {
+        ServletRequest  servletRequest  = (ServletRequest) facesContext.getExternalContext().getRequest();
+        ServletResponse servletResponse = (ServletResponse) facesContext.getExternalContext().getResponse();
+        String[]        params          = servletRequest.getParameterValues(PARAM_NAME);
+        String[]        spck2params     = servletRequest.getParameterValues(SPCK2_PARAM_NAME);
+
+        if ((params == null) && (spck2params == null))
+            return;
+
+        if (spck2params != null) {
+            handleAjaxRequest2(facesContext, spck2params);
+
+            return;
+        }
+
+        if (params.length == 1) {
+            PrintWriter writer = servletResponse.getWriter();
+            writer.write(HTMLDecoder.decode(removeSpan(params[0])));
+            servletResponse.flushBuffer();
+        } else if (params.length > 2) {
+            String        value   = params[0];
+            String        varname = params[1];
+            String        method  = params[2];
+            String        textStr = decodeValue(servletRequest, value);
+            MethodBinding mb      = getMethodBinding(facesContext, method);
+
+            if ((params.length >= 4) && "CHECK".equals(params[3])) {
+                checkSpelling(facesContext, servletResponse, mb, textStr, varname);
+            } else {
+                suggest(facesContext, servletResponse, mb, textStr, varname);
+            }
+        } else {
+            throw new RuntimeException("unexpected param.length " + params.length);
+        }
+    }
+
+    public void handleAjaxRequest2(FacesContext facesContext, String[] params) throws ServletException, IOException {
+        ServletRequest  servletRequest  = (ServletRequest) facesContext.getExternalContext().getRequest();
+        ServletResponse servletResponse = (ServletResponse) facesContext.getExternalContext().getResponse();
+        String          command         = params[0];
+        String          method          = null;
+
+        String content = servletRequest.getParameter("content");
+
+        if (command.equals("spellcheck")) {
+            method  = params[1];
+            content = removeSpan2(content);
+
+            MethodBinding mb = getMethodBinding(facesContext, method);
+
+            checkSpelling2(facesContext, servletResponse, mb, content);
+        } else if (command.equals("cleanup")) {
+            cleanup2(servletResponse, content);
+        } else if (command.equals("showsuggestions")) {
+            method = params[1];
+
+            MethodBinding mb = getMethodBinding(facesContext, method);
+            suggest2(facesContext, servletRequest, servletResponse, content, mb);
+        }
+
+    }
+
+
+    public String removeSpan(String value) {
+        StringBuffer buf     = new StringBuffer();
+        Matcher      matcher = SPAN.matcher(value);
+        int          idx     = 0;
+
+        while (matcher.find()) {
+            int start = matcher.start();
+            buf.append(value.substring(idx, start));
+            buf.append(matcher.group(2));
+            idx = matcher.end();
+        }
+
+        buf.append(value.substring(idx, value.length()));
+
+        return HTMLEncoder.encode(buf.toString(), true, false, true);
+    }
+
+    public String removeSpan2(String value) {
+        StringBuffer buf     = new StringBuffer();
+        Matcher      matcher = SPAN.matcher(value);
+        int          idx     = 0;
+
+        while (matcher.find()) {
+            int start = matcher.start();
+            buf.append(value.substring(idx, start));
+            buf.append(matcher.group(2));
+            idx = matcher.end();
+        }
+
+        buf.append(value.substring(idx, value.length()));
+
+        return buf.toString();
+    }
+
+    public int substitute(Matcher matcher, String value, List words, boolean html) {
+        int startIdx = 0;
+
+        if (matcher.find()) {
+            int    start  = matcher.start();
+            int    end    = matcher.end();
+            String before = value.substring(startIdx, start);
+            words.add(new Word(before, true, startIdx));
+
+            String subst = value.substring(start, end);
+
+            if (html) {
+                words.add(new Word("&lt;" + subst.substring(1, subst.length() - 1) + "&gt;", false, start));
+            } else {
+                words.add(new Word(subst, false, start));
+            }
+
+            if (end > value.length()) {
+                startIdx = substitute(matcher, value.substring(startIdx, value.length()), words, html);
+            } else {
+                startIdx = end;
+            }
+        }
+
+        return startIdx;
+    }
+
+    private static String encodeValue(String value) {
+        return HTMLEncoder.encode(value, true, false, true);
+    }
+
+    private static List extractWords(String value) {
+        List words = new ArrayList();
+        words.add(new Word(value, true, 0));
+
+        if (XHMTL_PATTERN.matcher(value).find())
+            words = splitWords(XHMTL_PATTERN, words, false);
+
+        if (URL_PATTERN.matcher(value).find())
+            words = splitWords(URL_PATTERN, words, false);
+
+        if (EMAIL_PATTERN.matcher(value).find())
+            words = splitWords(EMAIL_PATTERN, words, false);
+
+        if (ENUMERATION_PATTERN.matcher(value).find())
+            words = splitWords(ENUMERATION_PATTERN, words, false);
+
+        words = splitWords(WORDS_PATTERN, words, true);
+
+        return words;
+    }
+
+    private static List splitWords(Pattern pattern, List words, boolean checkSpelling) {
+        List newWords = new ArrayList((words.size() < 10) ? 50 : (words.size() * 2));
+
+        for (int i = 0; i < words.size(); i++) {
+            Word   word  = (Word) words.get(i);
+            String value = word.getValue();
+
+            if (word.checkSpelling) {
+                Matcher matcher = pattern.matcher(value);
+                int     idx     = 0;
+
+                while (matcher.find()) {
+                    int start = matcher.start();
+                    int end   = matcher.end();
+
+                    if (start > idx)
+                        newWords.add(new Word(value.substring(idx, start), !checkSpelling, idx));
+
+                    newWords.add(new Word(value.substring(start, end), checkSpelling, idx));
+                    idx = end;
+                }
+
+                if (idx < value.length())
+                    newWords.add(new Word(value.substring(idx, value.length()), !checkSpelling, idx));
+            } else {
+                newWords.add(word);
+            }
+        }
+
+        return newWords;
+    }
+
+    private void checkSpelling(FacesContext facesContext, ServletResponse servletResponse, MethodBinding mb, String textStr, String varname)
+        throws IOException {
+
+        if ((textStr == null) || (textStr.length() == 0))
+            return;
+
+        List         words = extractWords(textStr);
+        StringBuffer buf   = new StringBuffer();
+        mb.invoke(facesContext, new Object[] { new Text(words) });
+
+        boolean misspellingFound = false;
+
+        for (int i = 0, sizei = words.size(); i < sizei; i++) {
+            Word   word  = (Word) words.get(i);
+            String value = word.getValue();
+            value = encodeValue(value);
+
+            if (word.isInvalid()) {
+                misspellingFound = true;
+
+                String id = varname + "_" + i;
+                buf.append("\\u003cspan onclick=\"setCurrentObject(").append(varname).append(");");
+                buf.append("showSuggestions('").append(word.getValue()).append("','").append(id).append("');\" ");
+                buf.append("id=\"").append(id).append("\" ");
+                buf.append("class=\"highlight\"\\u003e");
+                buf.append(value);
+                buf.append("\\u003c/span\\u003e");
+            } else {
+                buf.append(value);
+            }
+        }
+
+        PrintWriter writer = servletResponse.getWriter();
+        writer.write(misspellingFound ? '1' : '0');
+        writer.write(buf.toString());
+        servletResponse.flushBuffer();
+    }
+
+    private void checkSpelling2(FacesContext facesContext, ServletResponse servletResponse, MethodBinding mb, String textStr)
+        throws IOException {
+
+        if ((textStr == null) || (textStr.length() == 0))
+            return;
+
+        List words = extractWords(textStr);
+        mb.invoke(facesContext, new Object[] { new Text(words) });
+
+        int          spellErrCnt = 0;
+        StringBuffer textBuilder = new StringBuffer(textStr.length() + 3);
+
+
+        for (int i = 0, sizei = words.size(); i < sizei; i++) {
+
+            Word currentWord = (Word) words.get(i);
+
+            if (currentWord.isInvalid()) {
+
+                textBuilder.append(" <span id='myfaces_SpellErr:" + spellErrCnt + "' class='myfaces_SpellingError'>" + currentWord.getValue() + "</span> ");
+                spellErrCnt++;
+            } else {
+                textBuilder.append(currentWord.getValue());
+            }
+        }
+
+        //servletResponse.setCharacterEncoding("utf-8");
+        servletResponse.setContentType("text/html");
+
+        PrintWriter writer = servletResponse.getWriter();
+        writer.write(textBuilder.toString());
+        servletResponse.flushBuffer();
+    }
+
+    private void cleanup2(ServletResponse servletResponse, String content) throws IOException {
+        content = removeSpan2(content);
+
+        //servletResponse.setCharacterEncoding("utf-8");
+        servletResponse.setContentType("text/html");
+
+        PrintWriter writer = servletResponse.getWriter();
+        writer.write(content);
+        servletResponse.flushBuffer();
+    }
+
+    private String decodeValue(ServletRequest servletRequest, String value) throws UnsupportedEncodingException {
+        String encoding = servletRequest.getCharacterEncoding();
+
+        if (encoding == null)
+            encoding = "iso-8859-1";
+
+        return URLDecoder.decode(URLEncoder.encode(value, encoding), "utf8");
+    }
+
+    private MethodBinding getMethodBinding(FacesContext facesContext, String method) {
+        MethodBinding mb = null;
+
+        if (UIComponentTag.isValueReference(method)) {
+            mb = facesContext.getApplication().createMethodBinding(method, new Class[] { Text.class });
+
+            if (mb == null)
+                throw new NullPointerException("Spellchecker Methodbinding must not be null");
+        }
+
+        return mb;
+    }
+
+    private void suggest(FacesContext facesContext, ServletResponse servletResponse, MethodBinding mb, String textStr, String varname)
+        throws IOException {
+        Word word = new Word(textStr, true, 0);
+        Text text = new Text(word);
+        mb.invoke(facesContext, new Object[] { text });
+
+        String[]     alternatives = word.getAlternatives();
+        StringBuffer buf          = new StringBuffer();
+
+        if ((alternatives != null) && (alternatives.length > 0)) {
+
+            for (int i = 0; i < alternatives.length; i++) {
+                buf.append("\\u003cdiv class=\"suggestion\" ");
+                buf.append("onclick=\"replaceWord('").append(varname).append("','").append(alternatives[i]).append("')\"");
+                buf.append("\\u003e").append(encodeValue(alternatives[i])).append("\\u003c/div\\u003e");
+            }
+        } else {
+            buf.append("\\u003cdiv class=\"suggestion\" ");
+            buf.append("onclick=\"replaceWord('-','-')\"");
+            buf.append("\\u003e-\\u003c/div\\u003e");
+        }
+
+        PrintWriter writer = servletResponse.getWriter();
+        writer.write(buf.toString());
+        servletResponse.flushBuffer();
+    }
+
+    private void suggest2(FacesContext facesContext, ServletRequest servletRequest, ServletResponse servletResponse, String content,
+            MethodBinding mb) throws IOException {
+        content = removeSpan2(content);
+
+        String targetid = servletRequest.getParameter("targetid");
+
+        if (targetid == null)
+            targetid = "";
+
+        Word word = new Word(content, true, 0);
+
+        //InputSuggestAjaxTest spellchecker = new InputSuggestAjaxTest();
+
+        mb.invoke(facesContext, new Object[] { new Text(word) });
+        //spellchecker.checkSpelling(new Text(word));
+
+        StringBuffer contentBuilder = new StringBuffer(254);
+
+        //";" separatet ist of results
+        contentBuilder.append("{noEntries: ");
+        contentBuilder.append(word.getAlternatives().length);
+        contentBuilder.append(",content: \"");
+
+        for (int cnt = 1; cnt <= word.getAlternatives().length; cnt++)
+            contentBuilder.append(("<li><div class='myfaces_SuggestEntry' id=':evt_target_id_corrid_" + cnt + "'>:correctionWord</div></li>").replaceAll("\\:evt_target_id", targetid).replaceAll("\\:correctionWord", word.getAlternatives()[
+                cnt - 1]));
+
+        contentBuilder.append("\"}");
+        //servletResponse.setCharacterEncoding("utf-8");
+        servletResponse.setContentType("text/html");
+
+        PrintWriter writer = servletResponse.getWriter();
+        writer.write(contentBuilder.toString());
+        servletResponse.flushBuffer();
+    }
+
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxSpellcheckerServlet.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxSpellcheckerServlet.java?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxSpellcheckerServlet.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/AjaxSpellcheckerServlet.java Wed May  3 14:24:53 2006
@@ -0,0 +1,70 @@
+package org.apache.myfaces.custom.pagelet;
+
+import java.io.IOException;
+
+import javax.faces.FactoryFinder;
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * @author Thomas Spiegl
+ */
+public class AjaxSpellcheckerServlet extends HttpServlet {
+
+    private static final String LIFECYCLE_ID_ATTR    = "javax.faces.LIFECYCLE_ID";
+    public static final String  AJAX_PATH            = "/org/apache/myfaces/ajax";
+    private static final String SERVLET_INFO         = "FacesServlet of the MyFaces API implementation";
+    private FacesContextFactory _facesContextFactory;
+    private Lifecycle           _lifecycle;
+    private ServletConfig       _servletConfig;
+
+    public static String getServletPath(ServletRequest request, String path) {
+        String context = ((HttpServletRequest) request).getContextPath();
+
+        return (context != null) ? (context + AjaxSpellcheckerServlet.AJAX_PATH + "/" + path) : (AjaxSpellcheckerServlet.AJAX_PATH + "/" + path);
+    }
+
+    public void destroy() {
+        _servletConfig       = null;
+        _facesContextFactory = null;
+        _lifecycle           = null;
+    }
+
+    public ServletConfig getServletConfig() {
+        return null;
+    }
+
+    public String getServletInfo() {
+        return SERVLET_INFO;
+    }
+
+    public void init(ServletConfig servletConfig) throws ServletException {
+        _servletConfig       = servletConfig;
+        _facesContextFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+
+        LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+        _lifecycle = lifecycleFactory.getLifecycle(getLifecycleId());
+    }
+
+    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
+        FacesContext          facesContext = _facesContextFactory.getFacesContext(_servletConfig.getServletContext(), servletRequest, servletResponse, _lifecycle);
+        AjaxSpellCheckHandler handler      = new AjaxSpellCheckHandler();
+        handler.handleAjaxRequest(facesContext);
+    }
+
+    private String getLifecycleId() {
+        String lifecycleId = _servletConfig.getServletContext().getInitParameter(LIFECYCLE_ID_ATTR);
+
+        return (lifecycleId != null) ? lifecycleId : LifecycleFactory.DEFAULT_LIFECYCLE;
+    }
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/BasePageletRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/BasePageletRenderer.java?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/BasePageletRenderer.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/BasePageletRenderer.java Wed May  3 14:24:53 2006
@@ -0,0 +1,297 @@
+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.ServletRequest;
+
+import org.apache.myfaces.renderkit.html.util.AddResource;
+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.HtmlTextareaRendererBase;
+
+
+/**
+ * Base pagelet class with common suffixes and prefixes
+ * and a set of accessor helpers easing
+ * the structures
+ *
+ * @author werpu
+ *
+ */
+public class BasePageletRenderer extends HtmlTextareaRendererBase {
+
+    protected static final String TEXTBOX_ID_SUFFIX = "_editor";
+    protected static final String DIV_ID_SUFFIX     = "_div";
+    protected static final String FORM_SUFFIX       = "_form";
+    protected static final String TEXT_AREA_SUFFIX  = "_ta";
+    protected static final String EDIT_DIV_SUFFIX   = TEXTBOX_ID_SUFFIX + "_edit_div";
+    protected static final String SERVLET_PATH      = "spellchecker";
+
+    protected static String asString(int value) {
+        return (value == 0) ? "null" : ("'" + Integer.toString(value) + "'");
+    }
+
+    protected static String asString(String value, String defaultValue) {
+
+        if (value == null) {
+            return (defaultValue == null) ? "null" : ("'" + defaultValue + "'");
+        }
+
+        return value;
+    }
+
+    protected String calcUniqueId(UIComponent uiComponent, FacesContext facesContext) {
+        String uniqueId = uiComponent.getClientId(facesContext).replaceAll(":", "_");
+
+        if (uniqueId.startsWith("_") && (uniqueId.length() > 1))
+            uniqueId = uniqueId.substring(1, uniqueId.length());
+
+        return uniqueId;
+    }
+
+    protected void endContentColum(ResponseWriter writer) throws IOException {
+        writer.endElement(HTML.TD_ELEM);
+    }
+
+    protected void endControlPanel(ResponseWriter writer) throws IOException {
+        writer.endElement("div");
+    }
+
+    protected void endPositionColumn(ResponseWriter writer) throws IOException {
+        writer.endElement(HTML.TD_ELEM);
+        writer.endElement(HTML.TR_ELEM);
+        writer.endElement(HTML.TABLE_ELEM);
+        writer.endElement(HTML.TD_ELEM);
+    }
+
+    protected void endWriterPositioningTable(ResponseWriter writer) throws IOException {
+        writer.endElement(HTML.TR_ELEM);
+        writer.endElement(HTML.TABLE_ELEM);
+    }
+
+    protected String getActionSpanId(String uniqueId) {
+        String actionSpanId = uniqueId + "action";
+
+        return actionSpanId;
+    }
+
+    protected String getPageletBackupControlId(String uniqueId) {
+        String backupControlId = uniqueId + "_ta"; // TODO check if this one is
+
+        // valid
+
+        return backupControlId;
+    }
+
+    protected String getPageletCancelId(String dialogId) {
+        return dialogId + "_cancel";
+    }
+
+    protected String getPageletClearId(String dialogId) {
+        return dialogId + "_clear";
+    }
+
+    protected String getPageletDialogId(String uniqueId) {
+        String dialogId = uniqueId + "DialogContent";
+
+        return dialogId;
+    }
+
+    protected String getPageletEditorId(String dialogId) {
+        return dialogId + "_editor";
+    }
+
+    protected String getPageletEventhandlerId(String uniqueId) {
+        return uniqueId + "EvtHandler";
+    }
+
+    protected String getPageletSpellerId(String dialogId) {
+        return dialogId + "_speller";
+    }
+
+    protected String getPageletSubmitterId(String dialogId) {
+        return dialogId + "_submitter";
+    }
+
+    protected String getResizeId(String uniqueId) {
+        String resizeSpanId = uniqueId + "resize";
+
+        return resizeSpanId;
+    }
+
+    protected String getSpellcheckServletPath(FacesContext facesContext) {
+
+        //TODO map this for the phase listener approach into a jsf call
+        return AjaxSpellcheckerServlet.getServletPath((ServletRequest) facesContext.getExternalContext().getRequest(), SERVLET_PATH);
+    }
+
+    protected String getStatusSpanId(String uniqueId) {
+        String statusSpanId = uniqueId + "status";
+
+        return statusSpanId;
+    }
+
+    protected String getZoomId(String uniqueId) {
+        String zoomSpanId = uniqueId + "zoom";
+
+        return zoomSpanId;
+    }
+
+    protected void startContentColum(ResponseWriter writer) throws IOException {
+        writer.startElement(HTML.TD_ELEM, null);
+    }
+
+    protected void startControlPanel(ResponseWriter writer, String divId) throws IOException {
+        writer.startElement("div", null);
+        writer.writeAttribute("id", divId, null);
+    }
+
+    protected void startPositionColumn(ResponseWriter writer) throws IOException {
+        writer.startElement(HTML.TD_ELEM, null);
+        writer.writeAttribute("VALIGN", "top", null);
+        writer.startElement(HTML.TABLE_ELEM, null);
+        writer.startElement(HTML.TR_ELEM, null);
+        writer.startElement(HTML.TD_ELEM, null);
+    }
+
+    protected void startWriterPositioningTable(ResponseWriter writer) throws IOException {
+        writer.startElement(HTML.TABLE_ELEM, null);
+        writer.startElement(HTML.TR_ELEM, null);
+    }
+
+    protected void writeBR(ResponseWriter writer) throws IOException {
+        writer.startElement(HTML.BR_ELEM, null);
+        writer.endElement(HTML.BR_ELEM);
+    }
+
+    protected void writeCancelImg(FacesContext facesContext, UIComponent uiComponent, ResponseWriter writer, String btcancelId,
+            String buttonStyle, AddResource addResource) throws IOException {
+        writer.startElement("div", uiComponent);
+        writer.writeAttribute("id", btcancelId, null);
+        writer.writeAttribute("style", buttonStyle, null);
+        writer.startElement("img", uiComponent);
+        writer.writeAttribute("alt", "[Cancel]", null);
+        writer.writeAttribute("src", addResource.getResourceUri(facesContext, PageletRenderer.class, "img/CANCEL_0.gif"), null);
+        writer.endElement("img");
+        writer.endElement("div");
+    }
+
+    protected void writeClearImage(FacesContext facesContext, UIComponent uiComponent, ResponseWriter writer, String btclearId,
+            String buttonStyle, AddResource addResource) throws IOException {
+        writer.startElement("div", uiComponent);
+        writer.writeAttribute("id", btclearId, null);
+        writer.writeAttribute("style", buttonStyle, null);
+        writer.startElement("img", uiComponent);
+        writer.writeAttribute("alt", "[Clear]", null);
+        writer.writeAttribute("src", addResource.getResourceUri(facesContext, PageletRenderer.class, "img/CLEAR_0.gif"), null);
+        writer.endElement("img");
+        writer.endElement("div");
+    }
+
+    protected void writeEditDiv(ResponseWriter writer, UIComponent uiComponent, String editDivId) throws IOException {
+        writer.startElement(HTML.DIV_ELEM, uiComponent);
+        writer.writeAttribute(HTML.ID_ATTR, editDivId, null);
+        writer.writeAttribute(HTML.STYLE_ATTR, "text-align:left;", null);
+        writer.endElement(HTML.DIV_ELEM);
+    }
+
+    protected void writeEmptyFloatRight(Pagelet spchk, ResponseWriter writer) throws IOException {
+        writer.startElement("div", spchk);
+        writer.writeAttribute("style", "float:right;", null);
+        writer.write("&nbsp;");
+        writer.endElement("div");
+    }
+
+    protected void writeOkImage(FacesContext facesContext, UIComponent uiComponent, ResponseWriter writer, String btsubmitterId,
+            String buttonStyle, AddResource addResource) throws IOException {
+        writer.startElement("div", uiComponent);
+        writer.writeAttribute("id", btsubmitterId, null);
+        writer.writeAttribute("style", buttonStyle, null);
+        writer.startElement("img", uiComponent);
+        writer.writeAttribute("alt", "[OK]", null);
+        writer.writeAttribute("src", addResource.getResourceUri(facesContext, PageletRenderer.class, "img/OK_0.gif"), null);
+        writer.endElement("img");
+        writer.endElement("div");
+    }
+
+    protected void writeResizerLinks(ResponseWriter writer, FacesContext context, Pagelet spellchk, String textAreaId,
+            String resizerId, String zoomId, boolean writeResizer, boolean writeZoom) throws IOException {
+
+        writer.startElement("span", null);
+        writer.writeAttribute("id", resizerId, null);
+
+        // if none of the zoom width and heights are set we go for sane values
+        // according
+        // due to different widths and heights of normal user screens (which can
+        // vary
+        // due to the shift towards widescreen, so we go for a 1:1.5 ratio to be
+        // in a safe
+        // area)
+        int zoomWidth = Math.max(spellchk.getWidth(), spellchk.getZoomWidth());
+
+        if (spellchk.getZoomWidth() == 0)
+            zoomWidth = spellchk.getWidth() + 150;
+
+        int zoomHeight = Math.max(spellchk.getHeight(), spellchk.getZoomHeight());
+
+        if (spellchk.getZoomHeight() == 0)
+            zoomHeight = spellchk.getHeight() + 100;
+
+        if (writeZoom) {
+
+            if (!spellchk.getControlMode().equals(Pagelet.COMTROL_MODE_PAGELET_RAWTEXT)) {
+                writer.startElement("div", null);
+                writer.writeAttribute("onclick", "myfaces_toggleZoomTa('" + textAreaId + "', " + zoomWidth + ", " + zoomHeight + ", 10);", null);
+                RendererUtils.renderChild(context, spellchk.getLinkZoom());
+                writer.endElement("div");
+                writeBR(writer);
+            } else {
+                writer.startElement("div", spellchk);
+                writer.writeAttribute("id", zoomId, null);
+                RendererUtils.renderChild(context, spellchk.getLinkZoom());
+                writer.endElement("div");
+                writeBR(writer);
+
+            }
+        }
+
+        if (writeResizer) {
+            writer.startElement("div", null);
+            writer.writeAttribute("onclick", "resizeTa('" + textAreaId + "', 20, " + zoomHeight + ");", null);
+            RendererUtils.renderChild(context, spellchk.getLinkResize());
+            writer.endElement("div");
+
+            writeBR(writer);
+
+            writer.startElement("div", null);
+            writer.writeAttribute("onclick", "downsizeTa('" + textAreaId + "', 20, " + spellchk.getHeight() + ");", null);
+            RendererUtils.renderChild(context, spellchk.getLinkDownsize());
+            writer.endElement("div");
+        }
+
+        writer.endElement("span");
+    }
+
+    protected void writeSpellcheckImage(FacesContext facesContext, UIComponent uiComponent, ResponseWriter writer, String btspellerId,
+            String buttonStyle, AddResource addResource) throws IOException {
+        writer.startElement("div", uiComponent);
+        writer.writeAttribute("id", btspellerId, null);
+        writer.writeAttribute("style", buttonStyle, null);
+        writer.startElement("img", uiComponent);
+        writer.writeAttribute("alt", "[Spellcheck]", null);
+        writer.writeAttribute("src", addResource.getResourceUri(facesContext, PageletRenderer.class, "img/SPELLCHECK_0.gif"), null);
+        writer.endElement("img");
+        writer.endElement("div");
+    }
+
+    protected void writeStatusSpan(ResponseWriter writer, String statusSpanId) throws IOException {
+        writer.startElement("span", null);
+        writer.writeAttribute("className", "status", null);
+        writer.writeAttribute("id", statusSpanId, null);
+        writer.endElement("span");
+    }
+
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/HTMLDecoder.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/HTMLDecoder.java?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/HTMLDecoder.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/HTMLDecoder.java Wed May  3 14:24:53 2006
@@ -0,0 +1,410 @@
+package org.apache.myfaces.custom.pagelet;
+
+import java.util.HashMap;
+
+/**
+ * Originally from com.websiteasp.ox pasckage.
+ *
+ * Author: Yves Lempereur
+ */
+public class HTMLDecoder {
+
+    private static final HashMap charTable;
+
+    public static String decode(String s) {
+        String t;
+        Character ch;
+        int tmpPos, i;
+
+        int maxPos = s.length();
+        StringBuffer sb = new StringBuffer(maxPos);
+        int curPos = 0;
+        while (curPos < maxPos) {
+            char c = s.charAt(curPos++);
+            if (c == '&') {
+                tmpPos = curPos;
+                if (tmpPos < maxPos) {
+                    char d = s.charAt(tmpPos++);
+                    if (d == '#') {
+                        if (tmpPos < maxPos) {
+                            d = s.charAt(tmpPos++);
+                            if (d == 'x' || d == 'X') {
+                                if (tmpPos < maxPos) {
+                                    d = s.charAt(tmpPos++);
+                                    if (isHexDigit(d)) {
+                                        while (tmpPos < maxPos) {
+                                            d = s.charAt(tmpPos++);
+                                            if (!isHexDigit(d)) {
+                                                if (d == ';') {
+                                                    t =
+                                                        s.substring(
+                                                            curPos + 2,
+                                                            tmpPos - 1);
+                                                    try {
+                                                        i =
+                                                            Integer.parseInt(
+                                                                t,
+                                                                16);
+                                                        if (i >= 0
+                                                            && i < 65536) {
+                                                            c = (char) i;
+                                                            curPos = tmpPos;
+                                                        }
+                                                    } catch (NumberFormatException e) {
+                                                    }
+                                                }
+                                                break;
+                                            }
+                                        }
+                                    }
+                                }
+                            } else if (isDigit(d)) {
+                                while (tmpPos < maxPos) {
+                                    d = s.charAt(tmpPos++);
+                                    if (!isDigit(d)) {
+                                        if (d == ';') {
+                                            t =
+                                                s.substring(
+                                                    curPos + 1,
+                                                    tmpPos - 1);
+                                            try {
+                                                i = Integer.parseInt(t);
+                                                if (i >= 0 && i < 65536) {
+                                                    c = (char) i;
+                                                    curPos = tmpPos;
+                                                }
+                                            } catch (NumberFormatException e) {
+                                            }
+                                        }
+                                        break;
+                                    }
+                                }
+                            }
+                        }
+                    } else if (isLetter(d)) {
+                        while (tmpPos < maxPos) {
+                            d = s.charAt(tmpPos++);
+                            if (!isLetterOrDigit(d)) {
+                                if (d == ';') {
+                                    t = s.substring(curPos, tmpPos - 1);
+                                    ch = (Character) charTable.get(t);
+                                    if (ch != null) {
+                                        c = ch.charValue();
+                                        curPos = tmpPos;
+                                    }
+                                }
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+            sb.append(c);
+        }
+        return sb.toString();
+    }
+
+    private static boolean isLetterOrDigit(char c) {
+        return isLetter(c) || isDigit(c);
+    }
+
+    private static boolean isHexDigit(char c) {
+        return isHexLetter(c) || isDigit(c);
+    }
+
+    private static boolean isLetter(char c) {
+        return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
+    }
+
+    private static boolean isHexLetter(char c) {
+        return (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
+    }
+
+    private static boolean isDigit(char c) {
+        return c >= '0' && c <= '9';
+    }
+
+    public static String compact(String s) {
+        int maxPos = s.length();
+        StringBuffer sb = new StringBuffer(maxPos);
+        int curPos = 0;
+        while (curPos < maxPos) {
+            char c = s.charAt(curPos++);
+            if (isWhitespace(c)) {
+                while (curPos < maxPos && isWhitespace(s.charAt(curPos))) {
+                    curPos++;
+                }
+                c = '\u0020';
+            }
+            sb.append(c);
+        }
+        return sb.toString();
+    }
+
+    // HTML is very particular about what constitutes white space.
+    public static boolean isWhitespace(char ch) {
+        return ch == '\u0020'
+            || ch == '\r'
+            || ch == '\n'
+            || ch == '\u0009'
+            || ch == '\u000c'
+            || ch == '\u200b';
+    }
+
+    static {
+        charTable = new HashMap();
+        charTable.put("quot", new Character((char) 34));
+        charTable.put("amp", new Character((char) 38));
+        charTable.put("apos", new Character((char) 39));
+        charTable.put("lt", new Character((char) 60));
+        charTable.put("gt", new Character((char) 62));
+        charTable.put("nbsp", new Character((char) 160));
+        charTable.put("iexcl", new Character((char) 161));
+        charTable.put("cent", new Character((char) 162));
+        charTable.put("pound", new Character((char) 163));
+        charTable.put("curren", new Character((char) 164));
+        charTable.put("yen", new Character((char) 165));
+        charTable.put("brvbar", new Character((char) 166));
+        charTable.put("sect", new Character((char) 167));
+        charTable.put("uml", new Character((char) 168));
+        charTable.put("copy", new Character((char) 169));
+        charTable.put("ordf", new Character((char) 170));
+        charTable.put("laquo", new Character((char) 171));
+        charTable.put("not", new Character((char) 172));
+        charTable.put("shy", new Character((char) 173));
+        charTable.put("reg", new Character((char) 174));
+        charTable.put("macr", new Character((char) 175));
+        charTable.put("deg", new Character((char) 176));
+        charTable.put("plusmn", new Character((char) 177));
+        charTable.put("sup2", new Character((char) 178));
+        charTable.put("sup3", new Character((char) 179));
+        charTable.put("acute", new Character((char) 180));
+        charTable.put("micro", new Character((char) 181));
+        charTable.put("para", new Character((char) 182));
+        charTable.put("middot", new Character((char) 183));
+        charTable.put("cedil", new Character((char) 184));
+        charTable.put("sup1", new Character((char) 185));
+        charTable.put("ordm", new Character((char) 186));
+        charTable.put("raquo", new Character((char) 187));
+        charTable.put("frac14", new Character((char) 188));
+        charTable.put("frac12", new Character((char) 189));
+        charTable.put("frac34", new Character((char) 190));
+        charTable.put("iquest", new Character((char) 191));
+        charTable.put("Agrave", new Character((char) 192));
+        charTable.put("Aacute", new Character((char) 193));
+        charTable.put("Acirc", new Character((char) 194));
+        charTable.put("Atilde", new Character((char) 195));
+        charTable.put("Auml", new Character((char) 196));
+        charTable.put("Aring", new Character((char) 197));
+        charTable.put("AElig", new Character((char) 198));
+        charTable.put("Ccedil", new Character((char) 199));
+        charTable.put("Egrave", new Character((char) 200));
+        charTable.put("Eacute", new Character((char) 201));
+        charTable.put("Ecirc", new Character((char) 202));
+        charTable.put("Euml", new Character((char) 203));
+        charTable.put("Igrave", new Character((char) 204));
+        charTable.put("Iacute", new Character((char) 205));
+        charTable.put("Icirc", new Character((char) 206));
+        charTable.put("Iuml", new Character((char) 207));
+        charTable.put("ETH", new Character((char) 208));
+        charTable.put("Ntilde", new Character((char) 209));
+        charTable.put("Ograve", new Character((char) 210));
+        charTable.put("Oacute", new Character((char) 211));
+        charTable.put("Ocirc", new Character((char) 212));
+        charTable.put("Otilde", new Character((char) 213));
+        charTable.put("Ouml", new Character((char) 214));
+        charTable.put("times", new Character((char) 215));
+        charTable.put("Oslash", new Character((char) 216));
+        charTable.put("Ugrave", new Character((char) 217));
+        charTable.put("Uacute", new Character((char) 218));
+        charTable.put("Ucirc", new Character((char) 219));
+        charTable.put("Uuml", new Character((char) 220));
+        charTable.put("Yacute", new Character((char) 221));
+        charTable.put("THORN", new Character((char) 222));
+        charTable.put("szlig", new Character((char) 223));
+        charTable.put("agrave", new Character((char) 224));
+        charTable.put("aacute", new Character((char) 225));
+        charTable.put("acirc", new Character((char) 226));
+        charTable.put("atilde", new Character((char) 227));
+        charTable.put("auml", new Character((char) 228));
+        charTable.put("aring", new Character((char) 229));
+        charTable.put("aelig", new Character((char) 230));
+        charTable.put("ccedil", new Character((char) 231));
+        charTable.put("egrave", new Character((char) 232));
+        charTable.put("eacute", new Character((char) 233));
+        charTable.put("ecirc", new Character((char) 234));
+        charTable.put("euml", new Character((char) 235));
+        charTable.put("igrave", new Character((char) 236));
+        charTable.put("iacute", new Character((char) 237));
+        charTable.put("icirc", new Character((char) 238));
+        charTable.put("iuml", new Character((char) 239));
+        charTable.put("eth", new Character((char) 240));
+        charTable.put("ntilde", new Character((char) 241));
+        charTable.put("ograve", new Character((char) 242));
+        charTable.put("oacute", new Character((char) 243));
+        charTable.put("ocirc", new Character((char) 244));
+        charTable.put("otilde", new Character((char) 245));
+        charTable.put("ouml", new Character((char) 246));
+        charTable.put("divide", new Character((char) 247));
+        charTable.put("oslash", new Character((char) 248));
+        charTable.put("ugrave", new Character((char) 249));
+        charTable.put("uacute", new Character((char) 250));
+        charTable.put("ucirc", new Character((char) 251));
+        charTable.put("uuml", new Character((char) 252));
+        charTable.put("yacute", new Character((char) 253));
+        charTable.put("thorn", new Character((char) 254));
+        charTable.put("yuml", new Character((char) 255));
+        charTable.put("OElig", new Character((char) 338));
+        charTable.put("oelig", new Character((char) 339));
+        charTable.put("Scaron", new Character((char) 352));
+        charTable.put("scaron", new Character((char) 353));
+        charTable.put("Yuml", new Character((char) 376));
+        charTable.put("fnof", new Character((char) 402));
+        charTable.put("circ", new Character((char) 710));
+        charTable.put("tilde", new Character((char) 732));
+        charTable.put("Alpha", new Character((char) 913));
+        charTable.put("Beta", new Character((char) 914));
+        charTable.put("Gamma", new Character((char) 915));
+        charTable.put("Delta", new Character((char) 916));
+        charTable.put("Epsilon", new Character((char) 917));
+        charTable.put("Zeta", new Character((char) 918));
+        charTable.put("Eta", new Character((char) 919));
+        charTable.put("Theta", new Character((char) 920));
+        charTable.put("Iota", new Character((char) 921));
+        charTable.put("Kappa", new Character((char) 922));
+        charTable.put("Lambda", new Character((char) 923));
+        charTable.put("Mu", new Character((char) 924));
+        charTable.put("Nu", new Character((char) 925));
+        charTable.put("Xi", new Character((char) 926));
+        charTable.put("Omicron", new Character((char) 927));
+        charTable.put("Pi", new Character((char) 928));
+        charTable.put("Rho", new Character((char) 929));
+        charTable.put("Sigma", new Character((char) 931));
+        charTable.put("Tau", new Character((char) 932));
+        charTable.put("Upsilon", new Character((char) 933));
+        charTable.put("Phi", new Character((char) 934));
+        charTable.put("Chi", new Character((char) 935));
+        charTable.put("Psi", new Character((char) 936));
+        charTable.put("Omega", new Character((char) 937));
+        charTable.put("alpha", new Character((char) 945));
+        charTable.put("beta", new Character((char) 946));
+        charTable.put("gamma", new Character((char) 947));
+        charTable.put("delta", new Character((char) 948));
+        charTable.put("epsilon", new Character((char) 949));
+        charTable.put("zeta", new Character((char) 950));
+        charTable.put("eta", new Character((char) 951));
+        charTable.put("theta", new Character((char) 952));
+        charTable.put("iota", new Character((char) 953));
+        charTable.put("kappa", new Character((char) 954));
+        charTable.put("lambda", new Character((char) 955));
+        charTable.put("mu", new Character((char) 956));
+        charTable.put("nu", new Character((char) 957));
+        charTable.put("xi", new Character((char) 958));
+        charTable.put("omicron", new Character((char) 959));
+        charTable.put("pi", new Character((char) 960));
+        charTable.put("rho", new Character((char) 961));
+        charTable.put("sigmaf", new Character((char) 962));
+        charTable.put("sigma", new Character((char) 963));
+        charTable.put("tau", new Character((char) 964));
+        charTable.put("upsilon", new Character((char) 965));
+        charTable.put("phi", new Character((char) 966));
+        charTable.put("chi", new Character((char) 967));
+        charTable.put("psi", new Character((char) 968));
+        charTable.put("omega", new Character((char) 969));
+        charTable.put("thetasym", new Character((char) 977));
+        charTable.put("upsih", new Character((char) 978));
+        charTable.put("piv", new Character((char) 982));
+        charTable.put("ensp", new Character((char) 8194));
+        charTable.put("emsp", new Character((char) 8195));
+        charTable.put("thinsp", new Character((char) 8201));
+        charTable.put("zwnj", new Character((char) 8204));
+        charTable.put("zwj", new Character((char) 8205));
+        charTable.put("lrm", new Character((char) 8206));
+        charTable.put("rlm", new Character((char) 8207));
+        charTable.put("ndash", new Character((char) 8211));
+        charTable.put("mdash", new Character((char) 8212));
+        charTable.put("lsquo", new Character((char) 8216));
+        charTable.put("rsquo", new Character((char) 8217));
+        charTable.put("sbquo", new Character((char) 8218));
+        charTable.put("ldquo", new Character((char) 8220));
+        charTable.put("rdquo", new Character((char) 8221));
+        charTable.put("bdquo", new Character((char) 8222));
+        charTable.put("dagger", new Character((char) 8224));
+        charTable.put("Dagger", new Character((char) 8225));
+        charTable.put("bull", new Character((char) 8226));
+        charTable.put("hellip", new Character((char) 8230));
+        charTable.put("permil", new Character((char) 8240));
+        charTable.put("prime", new Character((char) 8242));
+        charTable.put("Prime", new Character((char) 8243));
+        charTable.put("lsaquo", new Character((char) 8249));
+        charTable.put("rsaquo", new Character((char) 8250));
+        charTable.put("oline", new Character((char) 8254));
+        charTable.put("frasl", new Character((char) 8260));
+        charTable.put("euro", new Character((char) 8364));
+        charTable.put("image", new Character((char) 8465));
+        charTable.put("weierp", new Character((char) 8472));
+        charTable.put("real", new Character((char) 8476));
+        charTable.put("trade", new Character((char) 8482));
+        charTable.put("alefsym", new Character((char) 8501));
+        charTable.put("larr", new Character((char) 8592));
+        charTable.put("uarr", new Character((char) 8593));
+        charTable.put("rarr", new Character((char) 8594));
+        charTable.put("darr", new Character((char) 8595));
+        charTable.put("harr", new Character((char) 8596));
+        charTable.put("crarr", new Character((char) 8629));
+        charTable.put("lArr", new Character((char) 8656));
+        charTable.put("uArr", new Character((char) 8657));
+        charTable.put("rArr", new Character((char) 8658));
+        charTable.put("dArr", new Character((char) 8659));
+        charTable.put("hArr", new Character((char) 8660));
+        charTable.put("forall", new Character((char) 8704));
+        charTable.put("part", new Character((char) 8706));
+        charTable.put("exist", new Character((char) 8707));
+        charTable.put("empty", new Character((char) 8709));
+        charTable.put("nabla", new Character((char) 8711));
+        charTable.put("isin", new Character((char) 8712));
+        charTable.put("notin", new Character((char) 8713));
+        charTable.put("ni", new Character((char) 8715));
+        charTable.put("prod", new Character((char) 8719));
+        charTable.put("sum", new Character((char) 8721));
+        charTable.put("minus", new Character((char) 8722));
+        charTable.put("lowast", new Character((char) 8727));
+        charTable.put("radic", new Character((char) 8730));
+        charTable.put("prop", new Character((char) 8733));
+        charTable.put("infin", new Character((char) 8734));
+        charTable.put("ang", new Character((char) 8736));
+        charTable.put("and", new Character((char) 8743));
+        charTable.put("or", new Character((char) 8744));
+        charTable.put("cap", new Character((char) 8745));
+        charTable.put("cup", new Character((char) 8746));
+        charTable.put("int", new Character((char) 8747));
+        charTable.put("there4", new Character((char) 8756));
+        charTable.put("sim", new Character((char) 8764));
+        charTable.put("cong", new Character((char) 8773));
+        charTable.put("asymp", new Character((char) 8776));
+        charTable.put("ne", new Character((char) 8800));
+        charTable.put("equiv", new Character((char) 8801));
+        charTable.put("le", new Character((char) 8804));
+        charTable.put("ge", new Character((char) 8805));
+        charTable.put("sub", new Character((char) 8834));
+        charTable.put("sup", new Character((char) 8835));
+        charTable.put("nsub", new Character((char) 8836));
+        charTable.put("sube", new Character((char) 8838));
+        charTable.put("supe", new Character((char) 8839));
+        charTable.put("oplus", new Character((char) 8853));
+        charTable.put("otimes", new Character((char) 8855));
+        charTable.put("perp", new Character((char) 8869));
+        charTable.put("sdot", new Character((char) 8901));
+        charTable.put("lceil", new Character((char) 8968));
+        charTable.put("rceil", new Character((char) 8969));
+        charTable.put("lfloor", new Character((char) 8970));
+        charTable.put("rfloor", new Character((char) 8971));
+        charTable.put("lang", new Character((char) 9001));
+        charTable.put("rang", new Character((char) 9002));
+        charTable.put("loz", new Character((char) 9674));
+        charTable.put("spades", new Character((char) 9824));
+        charTable.put("clubs", new Character((char) 9827));
+        charTable.put("hearts", new Character((char) 9829));
+        charTable.put("diams", new Character((char) 9830));
+    }
+}
\ No newline at end of file

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Pagelet.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Pagelet.java?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Pagelet.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/Pagelet.java Wed May  3 14:24:53 2006
@@ -0,0 +1,331 @@
+package org.apache.myfaces.custom.pagelet;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.html.HtmlInputTextarea;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
+
+import org.apache.myfaces.shared_tomahawk.component.DisplayValueOnlyCapable;
+import org.apache.myfaces.shared_tomahawk.util._ComponentUtils;
+
+/**
+ * @author Thomas Spiegl
+ * minor additions and fixes done by Werner Punz
+ *
+ */
+public class Pagelet extends HtmlInputTextarea implements DisplayValueOnlyCapable {
+
+    //allowed control modes
+    public static final String   CONTROL_MODE_TEXTAREA         = "textarea";
+    public static final String   CONTROL_MODE_PAGELET          = "pagelet";
+    public static final String   COMTROL_MODE_PAGELET_RAWTEXT  = "pagelet-rawtext";
+    public static final String   CONTROL_MODE_PAGELET_TEXTAREA = "pagelet-richtext";
+    public static final String   COMPONENT_TYPE                = "org.apache.myfaces.Pagelet";
+    public static final String   DEFAULT_RENDERER_TYPE         = "org.apache.myfaces.Pagelet";
+    private static final String  LINK_SPELLCHECKER_FACET_NAME  = "linkSpellchecker";
+    private static final String  LINK_RESUME_FACET_NAME        = "linkResume";
+    private static final String  LINK_ZOOM_FACET_NAME          = "linkZoom";
+    private static final String  LINK_RESIZE_FACET_NAME        = "linkResize";
+    private static final String  LINK_DOWNSIZE_FACET_NAME      = "linkDownsize";
+    private static final String  LINK_POPUP_LABEL_FACET_NAME   = "popupLabel";
+    private static final boolean DEFAULT_DISPLAYVALUEONLY      = false;
+
+    private String        _controlMode;
+    private Boolean       _displayValueOnly           = null;
+    private String        _displayValueOnlyStyle      = null;
+    private String        _displayValueOnlyStyleClass = null;
+    private Integer       _height;
+    private MethodBinding _spellchecker;
+    private String        _textChecking;
+    private String        _textNoMisspellings;
+    private String        _textResume;
+    private String        _textSpellcheck;
+    private String        _textWorking;
+    private Integer       _width;
+    private Integer       _zoomHeight;
+    private Integer       _zoomWidth;
+
+    public Pagelet() {
+        setRendererType(DEFAULT_RENDERER_TYPE);
+    }
+
+    public String getControlMode() {
+        return _controlMode;
+    }
+
+    public String getDisplayValueOnlyStyle() {
+
+        if (_displayValueOnlyStyle != null)
+            return _displayValueOnlyStyle;
+
+        ValueBinding vb = getValueBinding("displayValueOnlyStyle");
+
+        return (vb != null) ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
+    }
+
+    public String getDisplayValueOnlyStyleClass() {
+
+        if (_displayValueOnlyStyleClass != null)
+            return _displayValueOnlyStyleClass;
+
+        ValueBinding vb = getValueBinding("displayValueOnlyStyleClass");
+
+        return (vb != null) ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
+    }
+
+    public int getHeight() {
+
+        if (_height != null)
+            return _height.intValue();
+
+        ValueBinding vb = getValueBinding("height");
+        Number       v  = (vb != null) ? (Number) vb.getValue(getFacesContext()) : null;
+
+        return (v != null) ? v.intValue() : 0;
+    }
+
+    public UIComponent getLinkDownsize() {
+        return (UIComponent) getFacets().get(LINK_DOWNSIZE_FACET_NAME);
+    }
+
+    public UIComponent getLinkResize() {
+        return (UIComponent) getFacets().get(LINK_RESIZE_FACET_NAME);
+    }
+
+    public UIComponent getLinkResume() {
+        return (UIComponent) getFacets().get(LINK_RESUME_FACET_NAME);
+    }
+
+    public UIComponent getLinkSpellchecker() {
+        return (UIComponent) getFacets().get(LINK_SPELLCHECKER_FACET_NAME);
+    }
+
+    public UIComponent getLinkZoom() {
+        return (UIComponent) getFacets().get(LINK_ZOOM_FACET_NAME);
+    }
+
+    public UIComponent getLinkPopupLabel() {
+    	 return (UIComponent) getFacets().get(LINK_POPUP_LABEL_FACET_NAME);
+    }
+    
+    public MethodBinding getSpellchecker() {
+        return _spellchecker;
+    }
+
+    public String getTextChecking() {
+
+        if (_textChecking != null)
+            return _textChecking;
+
+        ValueBinding vb = getValueBinding("textChecking");
+
+        return (vb != null) ? (String) vb.getValue(getFacesContext()) : null;
+    }
+
+    public String getTextNoMisspellings() {
+
+        if (_textNoMisspellings != null)
+            return _textNoMisspellings;
+
+        ValueBinding vb = getValueBinding("textNoError");
+
+        return (vb != null) ? (String) vb.getValue(getFacesContext()) : null;
+    }
+
+    public String getTextResume() {
+
+        if (_textResume != null)
+            return _textResume;
+
+        ValueBinding vb = getValueBinding("textResume");
+
+        return (vb != null) ? (String) vb.getValue(getFacesContext()) : null;
+    }
+
+    public String getTextSpellcheck() {
+
+        if (_textSpellcheck != null)
+            return _textSpellcheck;
+
+        ValueBinding vb = getValueBinding("textSpellcheck");
+
+        return (vb != null) ? (String) vb.getValue(getFacesContext()) : null;
+    }
+
+    public String getTextWorking() {
+
+        if (_textWorking != null)
+            return _textWorking;
+
+        ValueBinding vb = getValueBinding("textError");
+
+        return (vb != null) ? (String) vb.getValue(getFacesContext()) : null;
+    }
+
+    public int getWidth() {
+
+        if (_width != null)
+            return _width.intValue();
+
+        ValueBinding vb = getValueBinding("width");
+        Number       v  = (vb != null) ? (Number) vb.getValue(getFacesContext()) : null;
+
+        return (v != null) ? v.intValue() : 0;
+    }
+
+    public int getZoomHeight() {
+
+        if (_zoomHeight != null)
+            return _zoomHeight.intValue();
+
+        ValueBinding vb = getValueBinding("zoomHeight");
+        Number       v  = (vb != null) ? (Number) vb.getValue(getFacesContext()) : null;
+
+        return (v != null) ? v.intValue() : 0;
+    }
+
+    public int getZoomWidth() {
+
+        if (_zoomWidth != null)
+            return _zoomWidth.intValue();
+
+        ValueBinding vb = getValueBinding("zoomWidth");
+        Number       v  = (vb != null) ? (Number) vb.getValue(getFacesContext()) : null;
+
+        return (v != null) ? v.intValue() : 0;
+    }
+
+    public boolean isDisplayValueOnly() {
+
+        if (_displayValueOnly != null)
+            return _displayValueOnly.booleanValue();
+
+        ValueBinding vb = getValueBinding("displayValueOnly");
+        Boolean      v  = (vb != null) ? (Boolean) vb.getValue(getFacesContext()) : null;
+
+        return (v != null) ? v.booleanValue() : DEFAULT_DISPLAYVALUEONLY;
+    }
+
+    public boolean isSetDisplayValueOnly() {
+
+        if (_displayValueOnly != null)
+            return true;
+
+        ValueBinding vb = getValueBinding("displayValueOnly");
+        Boolean      v  = (vb != null) ? (Boolean) vb.getValue(getFacesContext()) : null;
+
+        return v != null;
+    }
+
+    public void restoreState(FacesContext facesContext, Object object) {
+        Object[] values = (Object[]) object;
+        super.restoreState(facesContext, values[0]);
+        _width                      = (Integer) values[1];
+        _height                     = (Integer) values[2];
+        _textSpellcheck             = (String) values[3];
+        _textResume                 = (String) values[4];
+        _textWorking                = (String) values[5];
+        _textNoMisspellings         = (String) values[6];
+        _zoomWidth                  = (Integer) values[7];
+        _zoomHeight                 = (Integer) values[8];
+        _spellchecker               = (MethodBinding) restoreAttachedState(facesContext, values[9]);
+        _displayValueOnly           = (Boolean) values[10];
+        _displayValueOnlyStyle      = (String) values[11];
+        _displayValueOnlyStyleClass = (String) values[12];
+        _controlMode                = (String) values[13];
+    }
+
+    public Object saveState(FacesContext facesContext) {
+        Object[] values = new Object[14];
+        values[0]  = super.saveState(facesContext);
+        values[1]  = _width;
+        values[2]  = _height;
+        values[3]  = _textSpellcheck;
+        values[4]  = _textResume;
+        values[5]  = _textWorking;
+        values[6]  = _textNoMisspellings;
+        values[7]  = _zoomWidth;
+        values[8]  = _zoomHeight;
+        values[9]  = saveAttachedState(facesContext, _spellchecker);
+        values[10] = _displayValueOnly;
+        values[11] = _displayValueOnlyStyle;
+        values[12] = _displayValueOnlyStyleClass;
+        values[13] = _controlMode;
+
+        return values;
+    }
+
+    public void setControlMode(String mode) {
+        _controlMode = mode;
+    }
+
+    public void setDisplayValueOnly(boolean displayValueOnly) {
+        _displayValueOnly = Boolean.valueOf(displayValueOnly);
+    }
+
+    public void setDisplayValueOnlyStyle(String displayValueOnlyStyle) {
+        _displayValueOnlyStyle = displayValueOnlyStyle;
+    }
+
+    public void setDisplayValueOnlyStyleClass(String displayValueOnlyStyleClass) {
+        _displayValueOnlyStyleClass = displayValueOnlyStyleClass;
+    }
+
+    public void setHeight(int height) {
+        _height = new Integer(height);
+    }
+
+    public void setLinkDownsize(UIComponent first) {
+        getFacets().put(LINK_DOWNSIZE_FACET_NAME, first);
+    }
+
+    public void setLinkResize(UIComponent first) {
+        getFacets().put(LINK_RESIZE_FACET_NAME, first);
+    }
+
+    public void setLinkResume(UIComponent first) {
+        getFacets().put(LINK_RESUME_FACET_NAME, first);
+    }
+
+    public void setLinkSpellchecker(UIComponent first) {
+        getFacets().put(LINK_SPELLCHECKER_FACET_NAME, first);
+    }
+
+    public void setSpellchecker(MethodBinding spellchecker) {
+        _spellchecker = spellchecker;
+    }
+
+    public void setTextChecking(String textChecking) {
+        _textChecking = textChecking;
+    }
+
+    public void setTextNoMisspellings(String textNoMisspellings) {
+        _textNoMisspellings = textNoMisspellings;
+    }
+
+    public void setTextResume(String textResume) {
+        _textResume = textResume;
+    }
+
+    public void setTextSpellcheck(String textSpellcheck) {
+        _textSpellcheck = textSpellcheck;
+    }
+
+    public void setTextWorking(String textWorking) {
+        _textWorking = textWorking;
+    }
+
+    public void setWidth(int width) {
+        _width = new Integer(width);
+    }
+
+    public void setZoomHeight(int zoomHeight) {
+        this._zoomHeight = new Integer(zoomHeight);
+    }
+
+    public void setZoomWidth(int zoomWidth) {
+        this._zoomWidth = new Integer(zoomWidth);
+    }
+
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/PageletRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/PageletRenderer.java?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/PageletRenderer.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/PageletRenderer.java Wed May  3 14:24:53 2006
@@ -0,0 +1,63 @@
+package org.apache.myfaces.custom.pagelet;
+
+import java.io.IOException;
+
+import java.util.Map;
+
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+
+/**
+ * @author Thomas Spiegl, Werner Punz
+ *
+ */
+public class PageletRenderer extends BasePageletRenderer {
+
+    // private static Log log =
+    // LogFactory.getLog(PageletRenderer.class);
+    SubrendererPagelet        pageletDelegate        = new SubrendererPagelet();
+    SubrendererPageletRawText pageletRawTextDelegate = new SubrendererPageletRawText();
+
+    //TODO other subrenderer delegates will follow
+    SubrendererTextarea textareaDelegate = new SubrendererTextarea();
+
+    public void decode(FacesContext facesContext, UIComponent uiComponent) {
+
+        // TODO decode
+        if (!(uiComponent instanceof EditableValueHolder)) {
+            throw new IllegalArgumentException("Component " + uiComponent.getClientId(facesContext) + " is not an EditableValueHolder");
+        }
+
+        Map    paramMap = facesContext.getExternalContext().getRequestParameterMap();
+        String uniqueId = calcUniqueId(uiComponent, facesContext);
+
+        // ((HttpServletRequest)facesContext.getExternalContext().getRequest()).getParameterMap()
+        String paramName = uniqueId + TEXT_AREA_SUFFIX;
+
+
+        if (paramMap.containsKey(paramName)) {
+            ((EditableValueHolder) uiComponent).setSubmittedValue(paramMap.get(paramName));
+        } // else if (paramMap.containsKey(backupControlParam)){
+    }
+
+    public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException {
+    	//super.encodeBegin(facesContext, uiComponent);
+
+    }
+
+    public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
+        Pagelet control     = (Pagelet) uiComponent;
+        String              controlMode = control.getControlMode();
+
+        if ((controlMode != null) && (controlMode.equals(Pagelet.CONTROL_MODE_TEXTAREA)))
+            textareaDelegate.encodeEnd(facesContext, uiComponent);
+        else if ((controlMode != null) && controlMode.equals(Pagelet.COMTROL_MODE_PAGELET_RAWTEXT))
+            pageletRawTextDelegate.encodeEnd(facesContext, uiComponent);
+        else
+            pageletDelegate.encodeEnd(facesContext, uiComponent);
+    }
+
+
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/PageletTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/PageletTag.java?rev=399437&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/PageletTag.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pagelet/PageletTag.java Wed May  3 14:24:53 2006
@@ -0,0 +1,152 @@
+package org.apache.myfaces.custom.pagelet;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.myfaces.shared_tomahawk.component.DisplayValueOnlyCapable;
+import org.apache.myfaces.shared_tomahawk.taglib.html.HtmlInputTextareaTagBase;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.webapp.UIComponentTag;
+
+
+/**
+ * @author Thomas Spiegl
+ *
+ */
+public class PageletTag extends HtmlInputTextareaTagBase {
+
+    private static final String WIDTH_ATTR               = "width".intern();
+    private static final String HEIGHT_ATTR              = "height".intern();
+    private static final String TXT_SPELLCHK_ATTR        = "textSpellcheck".intern();
+    private static final String TXT_RESUME_ATTR          = "textResume".intern();
+    private static final String TXT_WORKING_ATTR         = "textWorking".intern();
+    private static final String TXT_CHECKING_ATTR        = "textChecking".intern();
+    private static final String TXT_NO_MISSPELLINGS_ATTR = "textNoMisspellings".intern();
+    private static final String TXT_ZOOM_WIDTH_ATTR      = "zoomWidth".intern();
+    private static final String TXT_ZOOM_HEIGHT_ATTR     = "zoomHeight".intern();
+    private static final String TXT_CONTROL_MODE         = "controlMode".intern();
+
+    private String _controlMode;
+    private String _displayValueOnly;
+    private String _displayValueOnlyStyle;
+    private String _displayValueOnlyStyleClass;
+    private String _height, _zoomHeight;
+
+    private String _spellchecker;
+    private String _textSpellcheck, _textResume, _textWorking, _textNoMisspellings, _textChecking;
+    private String _width, _zoomWidth;
+
+    public static void setMethodProperty(FacesContext context, UIComponent component, String method) {
+
+        if (method != null) {
+
+            if (!(component instanceof Pagelet)) {
+                throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no AjaxInputSpellcheck");
+            }
+
+            if (UIComponentTag.isValueReference(method)) {
+                MethodBinding mb = context.getApplication().createMethodBinding(method, new Class[] { Text.class });
+                ((Pagelet) component).setSpellchecker(mb);
+            } else {
+                Log log = LogFactory.getLog(PageletTag.class);
+            	log.error("Invalid expression " + method);
+            }
+        }
+    }
+
+    public String getComponentType() {
+        return Pagelet.COMPONENT_TYPE;
+    }
+
+    public String getRendererType() {
+        return Pagelet.DEFAULT_RENDERER_TYPE;
+    }
+
+
+    public void release() {
+        super.release();
+        _spellchecker               = null;
+        _displayValueOnly           = null;
+        _displayValueOnlyStyle      = null;
+        _displayValueOnlyStyleClass = null;
+        _controlMode				= null;
+    }
+
+    public void setControlMode(String controlMode) {
+        this._controlMode = controlMode;
+    }
+
+    public void setDisplayValueOnly(String displayValueOnly) {
+        _displayValueOnly = displayValueOnly;
+    }
+
+    public void setDisplayValueOnlyStyle(String displayValueOnlyStyle) {
+        _displayValueOnlyStyle = displayValueOnlyStyle;
+    }
+
+    public void setDisplayValueOnlyStyleClass(String displayValueOnlyStyleClass) {
+        _displayValueOnlyStyleClass = displayValueOnlyStyleClass;
+    }
+
+    public void setHeight(String height) {
+        _height = height;
+    }
+
+    public void setSpellchecker(String spellchecker) {
+        _spellchecker = spellchecker;
+    }
+
+    public void setTextChecking(String textChecking) {
+        _textChecking = textChecking;
+    }
+
+    public void setTextNoMisspellings(String textNoMisspellings) {
+        _textNoMisspellings = textNoMisspellings;
+    }
+
+    public void setTextResume(String textResume) {
+        _textResume = textResume;
+    }
+
+    public void setTextSpellcheck(String textSpellcheck) {
+        _textSpellcheck = textSpellcheck;
+    }
+
+    public void setTextWorking(String textWorking) {
+        _textWorking = textWorking;
+    }
+
+    public void setWidth(String width) {
+        _width = width;
+    }
+
+    public void setZoomHeight(String zoomHeight) {
+        this._zoomHeight = zoomHeight;
+    }
+
+    public void setZoomWidth(String zoomWidth) {
+        this._zoomWidth = zoomWidth;
+    }
+
+    protected void setProperties(UIComponent uiComponent) {
+        super.setProperties(uiComponent);
+
+        setIntegerProperty(uiComponent, WIDTH_ATTR, _width);
+        setIntegerProperty(uiComponent, HEIGHT_ATTR, _height);
+        setStringProperty(uiComponent, TXT_SPELLCHK_ATTR, _textSpellcheck);
+        setStringProperty(uiComponent, TXT_RESUME_ATTR, _textResume);
+        setStringProperty(uiComponent, TXT_WORKING_ATTR, _textWorking);
+        setStringProperty(uiComponent, TXT_CHECKING_ATTR, _textChecking);
+        setStringProperty(uiComponent, TXT_NO_MISSPELLINGS_ATTR, _textNoMisspellings);
+        setIntegerProperty(uiComponent, TXT_ZOOM_WIDTH_ATTR, _zoomWidth);
+        setIntegerProperty(uiComponent, TXT_ZOOM_HEIGHT_ATTR, _zoomHeight);
+        setBooleanProperty(uiComponent, DisplayValueOnlyCapable.DISPLAY_VALUE_ONLY_ATTR, _displayValueOnly);
+        setStringProperty(uiComponent, DisplayValueOnlyCapable.DISPLAY_VALUE_ONLY_STYLE_ATTR, _displayValueOnlyStyle);
+        setStringProperty(uiComponent, DisplayValueOnlyCapable.DISPLAY_VALUE_ONLY_STYLE_CLASS_ATTR, _displayValueOnlyStyleClass);
+        setStringProperty(uiComponent, TXT_CONTROL_MODE, _controlMode);
+        setMethodProperty(getFacesContext(), uiComponent, _spellchecker);
+    }
+}



Mime
View raw message