You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/07/04 00:03:31 UTC

svn commit: r673836 [6/8] - in /myfaces/tomahawk/trunk: core/src/main/java/org/apache/myfaces/custom/buffer/ core/src/main/java/org/apache/myfaces/custom/calendar/ core/src/main/java/org/apache/myfaces/custom/captcha/ core/src/main/java/org/apache/myfa...

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java?rev=673836&r1=673835&r2=673836&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java Thu Jul  3 15:03:29 2008
@@ -1,444 +1,444 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.custom.passwordStrength;
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
-import javax.faces.component.html.HtmlInputText;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.Renderer;
-
-import org.apache.commons.lang.StringUtils;
-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;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
-import org.apache.myfaces.shared_tomahawk.util.MessageUtils;
-
-/**
- * 
- * @JSFRenderer
- *   renderKitId = "HTML_BASIC" 
- *   family = "org.apache.myfaces.PasswordStrength"
- *   type = "org.apache.myfaces.PasswordStrength"
- * 
- */
-public class PasswordStrengthRenderer extends Renderer {
-
-    private void addResources(FacesContext context, UIComponent component,
-            ResponseWriter writer) throws IOException {
-        PasswordStrengthComponent passwordStrength = (PasswordStrengthComponent) component;                
-        AddResource addResource = AddResourceFactory.getInstance(context);
-        
-        // Load the css style ...
-        String styleLocation = (String) component.getAttributes().get(
-                JSFAttr.STYLE_LOCATION);
-        if (StringUtils.isNotBlank(styleLocation)) {
-            addResource.addStyleSheet(context, AddResource.HEADER_BEGIN,
-                    styleLocation + "/passwordStrength.css");
-        } else {
-            addResource.addStyleSheet(context, AddResource.HEADER_BEGIN,
-                    PasswordStrengthRenderer.class, "css/passwordStrength.css");
-        }
-        
-        // Load the JS file ...
-        String javascriptLocation = (String) component.getAttributes().get(
-                JSFAttr.JAVASCRIPT_LOCATION);
-        if (javascriptLocation != null) {
-            addResource.addJavaScriptAtPosition(context,
-                    AddResource.HEADER_BEGIN, javascriptLocation
-                            + "/passwordStrength.js");
-        } else {
-            addResource.addJavaScriptAtPosition(context,
-                    AddResource.HEADER_BEGIN, PasswordStrengthRenderer.class,
-                    "passwordStrength.js");
-        }
-        
-        //Add Dojo stuff for progress bar ...
-        addDojoStuff(context, component);
-        
-        //Add Initialization stuff ...
-        String messageId = getMessageID(context, passwordStrength);
-        writer.write("<script type=\"text/javascript\">");    
-        String addOnStartUP = "dojo.addOnLoad(function() {"
-                + "startUpPasswordStrength('"
-                + messageId
-                + "'); });";
-        writer.write( addOnStartUP );
-        writer.write("</script>");
-    }
-    
-    private String getMessageID(FacesContext context,
-            PasswordStrengthComponent passwordStrength) {
-        String clientID = passwordStrength.getClientId(context);        
-        String messageId = "";
-        if (TextIndicatorType.TEXT
-                .equalsIgnoreCase(getStrengthIndicatorTypeValue(passwordStrength))) {
-            messageId = getIndicatorMessageId(clientID);
-        } else {
-            messageId = getProgressBarContainerID(clientID);
-        }
-        return messageId;
-    }
-    
-    private void addDojoStuff(FacesContext context, UIComponent component)
-            throws IOException {
-        String javascriptLocation = (String) component.getAttributes().get(
-                JSFAttr.JAVASCRIPT_LOCATION);
-        DojoUtils.addMainInclude(context, component, javascriptLocation,
-                DojoUtils.getDjConfigInstance(context));
-        DojoUtils.addRequire(context, component, "dojo.widget.ProgressBar");
-    }
-
-    private void renderStartDiv(UIComponent component, ResponseWriter writer)
-            throws IOException {
-
-        writer.startElement(HTML.DIV_ELEM, component);
-
-        writer.startElement(HTML.TABLE_ELEM, component);
-
-        writer.startElement(HTML.TR_ELEM, component);
-        writer.startElement(HTML.TD_ELEM, component);
-    }
-
-    private void renderEndDiv(UIComponent component, ResponseWriter writer)
-            throws IOException {
-        writer.endElement(HTML.TD_ELEM);
-        writer.endElement(HTML.TR_ELEM);
-
-        writer.endElement(HTML.TABLE_ELEM);
-
-        writer.endElement(HTML.DIV_ELEM);
-    }
-
-    private String getDefaultTextDesc() {
-        return MessageUtils.getMessage(BUNDLE_BASE_NAME,
-                MessageUtils.getCurrentLocale(),
-                "org.apache.myfaces.custom.passwordStrength.DESC", null)
-                .getDetail();
-    }
-    
-    private String getDefaultShowDetails() {
-        return "true";
-    }
-
-    private String getDefaultUseCustomSecurity() {
-        return "false";
-    }    
-
-    private String getDefaultCustomSecurityRule() {
-        return "A1";
-    }
-    
-    private String getDefaultPenaltyRatio() {
-        return "50";
-    }            
-    
-    private String getDefaultPrefix() {
-        return MessageUtils.getMessage(BUNDLE_BASE_NAME,
-                MessageUtils.getCurrentLocale(),
-                "org.apache.myfaces.custom.passwordStrength.PREFIX", null)
-                .getDetail();
-    }
-    
-    private String getLeftCharactersString() {
-        return "'" + MessageUtils.getMessage(BUNDLE_BASE_NAME,
-                MessageUtils.getCurrentLocale(),
-                "org.apache.myfaces.custom.passwordStrength.LEFT_CHARS", null)
-                .getDetail() + "'";        
-    }
-    
-    private String getDefaultStrengthIndicatorType() {
-        return TextIndicatorType.TEXT;
-    }    
-
-    private void createTextSpan(PasswordStrengthComponent passwordStrength,
-            FacesContext context, String clientID) throws IOException {
-        ResponseWriter writer = context.getResponseWriter();
-
-        String preferredLength = passwordStrength.getPreferredPasswordLength();
-        String prefixText = (passwordStrength.getPrefixText() == null) ? "'" + getDefaultPrefix() + "'"
-                : "'" + passwordStrength.getPrefixText() + "'";
-        String textStrengthDescriptions = (passwordStrength
-                .getTextStrengthDescriptions() == null) ? "'"
-                + getDefaultTextDesc() + "'" : "'"
-                + passwordStrength.getTextStrengthDescriptions() + "'";
-        String textID = "'" + clientID + "'";
-        String showDetails = (passwordStrength.getShowDetails() == null) ? "'"
-                + getDefaultShowDetails() + "'" : "'"
-                + passwordStrength.getShowDetails().toLowerCase() + "'";
-        
-        String useCustomSecurity = (passwordStrength.getUseCustomSecurity() == null) ? "'"
-                + getDefaultUseCustomSecurity() + "'"
-                : "'" + passwordStrength.getUseCustomSecurity().toLowerCase()
-                        + "'";
-
-        String customSecurityExpression = (passwordStrength
-                .getCustomSecurityExpression() == null) ? "'"
-                + getDefaultCustomSecurityRule() + "'" : "'"
-                + passwordStrength.getCustomSecurityExpression() + "'";        
-                
-                
-        String     penaltyRatio = (passwordStrength
-                .getPenaltyRatio() == null) ? "'"
-                + getDefaultPenaltyRatio() + "'" : "'"
-                + passwordStrength.getPenaltyRatio() + "'";                    
-
-        writer.startElement(HTML.SPAN_ELEM, passwordStrength);
-
-        writer.startElement(HTML.INPUT_ELEM, passwordStrength);
-        writer.writeAttribute(HTML.TYPE_ATTR, "password", HTML.TYPE_ATTR);
-        writer.writeAttribute(HTML.ID_ATTR, clientID, HTML.ID_ATTR);
-        writer.writeAttribute(HTML.NAME_ATTR, clientID, HTML.NAME_ATTR);
-
-        String value = "";
-        Object objValue = ((UIInput) passwordStrength).getSubmittedValue();
-        if (objValue != null) {
-            value = passwordStrength.getValue().toString();
-        }
-        writer.writeAttribute("value", value, "value");
-
-        writer.writeAttribute("onkeyup", createOnKeyUpString(context,
-                passwordStrength, textID, preferredLength, prefixText,
-                textStrengthDescriptions, true, showDetails, useCustomSecurity,
-                customSecurityExpression, penaltyRatio), "onkeyup");
-        writer.writeAttribute("onblur", getOnBlurString(context, passwordStrength), "onblur");
-
-        writer.endElement(HTML.INPUT_ELEM);
-
-        writer.endElement(HTML.SPAN_ELEM);
-    }
-
-    
-    private void createTextIndicatorMessage(UIComponent component,
-            FacesContext context, ResponseWriter writer) throws IOException {
-        String clientID = component.getClientId(context);
-        
-        writer.startElement(HTML.SPAN_ELEM, component);
-        writer.writeAttribute(HTML.ID_ATTR, getIndicatorMessageId( clientID ),
-                HTML.ID_ATTR);
-        writer.writeAttribute(HTML.CLASS_ATTR, "indicatorMessage",
-                HTML.CLASS_ATTR);
-        writer.endElement(HTML.SPAN_ELEM);        
-    }
-    
-    private void createIndicatorSpan(UIComponent component,
-            FacesContext context, ResponseWriter writer) throws IOException {
-        PasswordStrengthComponent passwordStrength = (PasswordStrengthComponent) component;
-    
-        String clientID = passwordStrength.getClientId(context);
-        String strengthIndicatorType =     getStrengthIndicatorTypeValue(passwordStrength);
-
-        writer.endElement(HTML.TD_ELEM);
-        writer.startElement(HTML.TD_ELEM, component);
-
-        if(TextIndicatorType.TEXT.equalsIgnoreCase( strengthIndicatorType )) { //It is a text ...
-            createTextIndicatorMessage(component, context, writer);
-        } else { //It is a progressbar ...     
-            createProgressBarSpan(component, context, writer);
-        }
-
-        writer.endElement(HTML.TD_ELEM);
-        writer.endElement(HTML.TR_ELEM);
-
-        writer.startElement(HTML.TR_ELEM, component);
-        writer.startElement(HTML.TD_ELEM, component);
-
-        writer.startElement("div", component);
-        writer.writeAttribute("id", getleftCharsMessageId(clientID), "id");
-        writer.endElement("div");
-    }
-    
-    private String getStrengthIndicatorType(
-            PasswordStrengthComponent passwordStrength) {
-        return (passwordStrength.getStrengthIndicatorType() == null) ? "'"
-                + getDefaultStrengthIndicatorType() + "'" : "'"
-                + passwordStrength.getStrengthIndicatorType() + "'";
-    }
-
-    private String getStrengthIndicatorTypeValue(
-            PasswordStrengthComponent passwordStrength) {
-        return (passwordStrength.getStrengthIndicatorType() == null) ? getDefaultStrengthIndicatorType()
-                : passwordStrength.getStrengthIndicatorType();
-    }    
-    
-    private void createProgressBarSpan(UIComponent component,
-            FacesContext context, ResponseWriter writer) throws IOException {
-        String clientID = component.getClientId(context);
-
-        writer.startElement(HTML.SPAN_ELEM, component);        
-        writer.writeAttribute("id", getProgressBarContainerID(clientID), "id");    
-        
-        writer.startElement(HTML.SPAN_ELEM, component);
-        writer.writeAttribute("width", DEFAULT_PROGRESSBAR_WIDTH, "width");
-        writer.writeAttribute("height", DEFAULT_PROGRESSBAR_HEIGHT, "height");
-        writer.writeAttribute("progressValue", DEFAULT_PROGRESSBAR_VALUE, "progressValue");                
-        //writer.writeAttribute("hasText", "true", "hasText");
-        writer.writeAttribute("dojoType", "ProgressBar", "dojoType");        
-        writer.writeAttribute("id", getProgressBarID(clientID), "id");        
-        writer.endElement(HTML.SPAN_ELEM);
-        
-        writer.endElement(HTML.SPAN_ELEM);                
-    }
-
-    private void createHTMLComponents(FacesContext facesContext,
-            UIComponent component, ResponseWriter writer, String clientID)
-            throws IOException {
-        PasswordStrengthComponent passwordStrength = (PasswordStrengthComponent) component;
-
-        renderStartDiv(component, writer);
-
-        createTextSpan(passwordStrength, facesContext, clientID);
-
-        createIndicatorSpan(component, facesContext, writer);
-
-        renderEndDiv(component, writer);
-    }
-
-    public void encodeBegin(FacesContext context, UIComponent component)
-            throws IOException {
-        RendererUtils.checkParamValidity(context, component,
-                PasswordStrengthComponent.class);
-
-        if (HtmlRendererUtils.isDisplayValueOnly(component)
-                || isDisabled(context, component)) {
-            super.encodeEnd(context, component);
-            return;
-        }
-
-        String clientID = component.getClientId(context);
-
-        ResponseWriter writer = context.getResponseWriter();
-
-        addResources(context, component, writer);
-
-        createHTMLComponents(context, component, writer, clientID);
-    }
-
-    public void encodeEnd(FacesContext context, UIComponent component)
-            throws IOException {
-    }
-
-    public void decode(FacesContext context, UIComponent component) {
-        Map requestMap = context.getExternalContext().getRequestParameterMap();
-
-        String clientID = component.getClientId(context);
-
-        String newValue = (String) requestMap.get(clientID);
-
-        ((UIInput) component).setSubmittedValue(newValue);
-    }
-
-    protected boolean isDisabled(FacesContext facesContext,
-            UIComponent component) {
-        if (component instanceof HtmlInputText) {
-            return ((HtmlInputText) component).isDisabled();
-        } else {
-            return org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils
-                    .getBooleanAttribute(component, HTML.DISABLED_ATTR, false);
-        }
-    }
-
-    private String createOnKeyUpString(FacesContext context,
-            UIComponent component, String textID, String preferredLength,
-            String prefix, String textStrengthDescriptions,
-            boolean showMessageIndicator, String showDetails,
-            String useCustomSecurity, String customSecurityExpression,
-            String penaltyRatio) {
-        
-        PasswordStrengthComponent passwordStrength = (PasswordStrengthComponent) component;
-
-        String clientID = component.getClientId(context);
-        String showMessageIndicatorString = "";
-        String strengthIndicatorType = getStrengthIndicatorType(passwordStrength);
-        String progressBarId = "'" + getProgressBarID(clientID) + "'";
-        String indicatorMessageID = "'" + getIndicatorMessageId(clientID) + "'";
-        String leftCharsMessageID = "'" + getleftCharsMessageId(clientID) + "'";
-
-        if (showMessageIndicator == true) {
-            showMessageIndicatorString = "show('"
-                    + getMessageID(context, passwordStrength) + "');";
-        }
-
-        return updateStatusValue(textID, preferredLength, prefix,
-                textStrengthDescriptions, indicatorMessageID,
-                leftCharsMessageID, showMessageIndicatorString,
-                strengthIndicatorType, progressBarId, showDetails,
-                getLeftCharactersString(), useCustomSecurity,
-                customSecurityExpression, penaltyRatio);
-    }
-    
-    private String updateStatusValue(String textID, String preferredLength,
-                                     String prefix, String textStrengthDescriptions,
-                                     String indicatorMessageID, String leftCharsMessageID,                                     
-                                     String showMessageIndicatorString, 
-                                     String strengthIndicatorType, String progressBarId, 
-                                     String showDetails, String leftCharactersString,
-                                     String useCustomSecurity, String customSecurityExpression,
-                                     String penaltyRatio) {
-        return "updateStatusValue(" 
-                + textID + "," + preferredLength + ", "
-                + prefix + ", " + textStrengthDescriptions + ", " 
-                + indicatorMessageID + ", " + leftCharsMessageID + ", "                
-                + strengthIndicatorType + ", " + progressBarId + ", "                 
-                + showDetails + ", " + leftCharactersString + ", "     
-                + useCustomSecurity + ", " + customSecurityExpression + ", "
-                + penaltyRatio
-                + ");"            
-                + showMessageIndicatorString;
-    }
-    
-    private String getIndicatorMessageId(String clientID) {    
-        return clientID + "indicatorMessage";
-    }
-    
-    private String getleftCharsMessageId(String clientID) {    
-        return clientID + "leftCharsMessage";
-    }    
-
-    private String getProgressBarID(String clientID) {    
-        return clientID + PROGRESSBAR_SUFFIX;
-    }
-    
-    private String getProgressBarContainerID(String clientID) {    
-        return getProgressBarID(clientID) + PROGRESSBAR_CONTAINER_SUFFIX;
-    }            
-    
-    private String getOnBlurString(FacesContext context, UIComponent component) {
-        PasswordStrengthComponent passwordStrength = (PasswordStrengthComponent) component;        
-        String clientID = passwordStrength.getClientId(context);        
-        
-        return "hide('" + getMessageID(context, passwordStrength) + "');" + "hide('"
-                + getleftCharsMessageId(clientID) + "');";
-    }
-
-    final String BUNDLE_BASE_NAME = "org.apache.myfaces.custom.passwordStrength.resource.PasswordStrength";
-    final String DEFAULT_PROGRESSBAR_WIDTH = "150";
-    final String DEFAULT_PROGRESSBAR_HEIGHT = "20";    
-    final String PROGRESSBAR_SUFFIX = "_PROGRESSBAR";
-    final String PROGRESSBAR_CONTAINER_SUFFIX = "_CONTAINER";    
-    final String DEFAULT_PROGRESSBAR_VALUE = "20";
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.passwordStrength;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
+import org.apache.commons.lang.StringUtils;
+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;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+import org.apache.myfaces.shared_tomahawk.util.MessageUtils;
+
+/**
+ * 
+ * @JSFRenderer
+ *   renderKitId = "HTML_BASIC" 
+ *   family = "org.apache.myfaces.PasswordStrength"
+ *   type = "org.apache.myfaces.PasswordStrength"
+ * 
+ */
+public class PasswordStrengthRenderer extends Renderer {
+
+    private void addResources(FacesContext context, UIComponent component,
+            ResponseWriter writer) throws IOException {
+        PasswordStrengthComponent passwordStrength = (PasswordStrengthComponent) component;                
+        AddResource addResource = AddResourceFactory.getInstance(context);
+        
+        // Load the css style ...
+        String styleLocation = (String) component.getAttributes().get(
+                JSFAttr.STYLE_LOCATION);
+        if (StringUtils.isNotBlank(styleLocation)) {
+            addResource.addStyleSheet(context, AddResource.HEADER_BEGIN,
+                    styleLocation + "/passwordStrength.css");
+        } else {
+            addResource.addStyleSheet(context, AddResource.HEADER_BEGIN,
+                    PasswordStrengthRenderer.class, "css/passwordStrength.css");
+        }
+        
+        // Load the JS file ...
+        String javascriptLocation = (String) component.getAttributes().get(
+                JSFAttr.JAVASCRIPT_LOCATION);
+        if (javascriptLocation != null) {
+            addResource.addJavaScriptAtPosition(context,
+                    AddResource.HEADER_BEGIN, javascriptLocation
+                            + "/passwordStrength.js");
+        } else {
+            addResource.addJavaScriptAtPosition(context,
+                    AddResource.HEADER_BEGIN, PasswordStrengthRenderer.class,
+                    "passwordStrength.js");
+        }
+        
+        //Add Dojo stuff for progress bar ...
+        addDojoStuff(context, component);
+        
+        //Add Initialization stuff ...
+        String messageId = getMessageID(context, passwordStrength);
+        writer.write("<script type=\"text/javascript\">");    
+        String addOnStartUP = "dojo.addOnLoad(function() {"
+                + "startUpPasswordStrength('"
+                + messageId
+                + "'); });";
+        writer.write( addOnStartUP );
+        writer.write("</script>");
+    }
+    
+    private String getMessageID(FacesContext context,
+            PasswordStrengthComponent passwordStrength) {
+        String clientID = passwordStrength.getClientId(context);        
+        String messageId = "";
+        if (TextIndicatorType.TEXT
+                .equalsIgnoreCase(getStrengthIndicatorTypeValue(passwordStrength))) {
+            messageId = getIndicatorMessageId(clientID);
+        } else {
+            messageId = getProgressBarContainerID(clientID);
+        }
+        return messageId;
+    }
+    
+    private void addDojoStuff(FacesContext context, UIComponent component)
+            throws IOException {
+        String javascriptLocation = (String) component.getAttributes().get(
+                JSFAttr.JAVASCRIPT_LOCATION);
+        DojoUtils.addMainInclude(context, component, javascriptLocation,
+                DojoUtils.getDjConfigInstance(context));
+        DojoUtils.addRequire(context, component, "dojo.widget.ProgressBar");
+    }
+
+    private void renderStartDiv(UIComponent component, ResponseWriter writer)
+            throws IOException {
+
+        writer.startElement(HTML.DIV_ELEM, component);
+
+        writer.startElement(HTML.TABLE_ELEM, component);
+
+        writer.startElement(HTML.TR_ELEM, component);
+        writer.startElement(HTML.TD_ELEM, component);
+    }
+
+    private void renderEndDiv(UIComponent component, ResponseWriter writer)
+            throws IOException {
+        writer.endElement(HTML.TD_ELEM);
+        writer.endElement(HTML.TR_ELEM);
+
+        writer.endElement(HTML.TABLE_ELEM);
+
+        writer.endElement(HTML.DIV_ELEM);
+    }
+
+    private String getDefaultTextDesc() {
+        return MessageUtils.getMessage(BUNDLE_BASE_NAME,
+                MessageUtils.getCurrentLocale(),
+                "org.apache.myfaces.custom.passwordStrength.DESC", null)
+                .getDetail();
+    }
+    
+    private String getDefaultShowDetails() {
+        return "true";
+    }
+
+    private String getDefaultUseCustomSecurity() {
+        return "false";
+    }    
+
+    private String getDefaultCustomSecurityRule() {
+        return "A1";
+    }
+    
+    private String getDefaultPenaltyRatio() {
+        return "50";
+    }            
+    
+    private String getDefaultPrefix() {
+        return MessageUtils.getMessage(BUNDLE_BASE_NAME,
+                MessageUtils.getCurrentLocale(),
+                "org.apache.myfaces.custom.passwordStrength.PREFIX", null)
+                .getDetail();
+    }
+    
+    private String getLeftCharactersString() {
+        return "'" + MessageUtils.getMessage(BUNDLE_BASE_NAME,
+                MessageUtils.getCurrentLocale(),
+                "org.apache.myfaces.custom.passwordStrength.LEFT_CHARS", null)
+                .getDetail() + "'";        
+    }
+    
+    private String getDefaultStrengthIndicatorType() {
+        return TextIndicatorType.TEXT;
+    }    
+
+    private void createTextSpan(PasswordStrengthComponent passwordStrength,
+            FacesContext context, String clientID) throws IOException {
+        ResponseWriter writer = context.getResponseWriter();
+
+        String preferredLength = passwordStrength.getPreferredPasswordLength();
+        String prefixText = (passwordStrength.getPrefixText() == null) ? "'" + getDefaultPrefix() + "'"
+                : "'" + passwordStrength.getPrefixText() + "'";
+        String textStrengthDescriptions = (passwordStrength
+                .getTextStrengthDescriptions() == null) ? "'"
+                + getDefaultTextDesc() + "'" : "'"
+                + passwordStrength.getTextStrengthDescriptions() + "'";
+        String textID = "'" + clientID + "'";
+        String showDetails = (passwordStrength.getShowDetails() == null) ? "'"
+                + getDefaultShowDetails() + "'" : "'"
+                + passwordStrength.getShowDetails().toLowerCase() + "'";
+        
+        String useCustomSecurity = (passwordStrength.getUseCustomSecurity() == null) ? "'"
+                + getDefaultUseCustomSecurity() + "'"
+                : "'" + passwordStrength.getUseCustomSecurity().toLowerCase()
+                        + "'";
+
+        String customSecurityExpression = (passwordStrength
+                .getCustomSecurityExpression() == null) ? "'"
+                + getDefaultCustomSecurityRule() + "'" : "'"
+                + passwordStrength.getCustomSecurityExpression() + "'";        
+                
+                
+        String     penaltyRatio = (passwordStrength
+                .getPenaltyRatio() == null) ? "'"
+                + getDefaultPenaltyRatio() + "'" : "'"
+                + passwordStrength.getPenaltyRatio() + "'";                    
+
+        writer.startElement(HTML.SPAN_ELEM, passwordStrength);
+
+        writer.startElement(HTML.INPUT_ELEM, passwordStrength);
+        writer.writeAttribute(HTML.TYPE_ATTR, "password", HTML.TYPE_ATTR);
+        writer.writeAttribute(HTML.ID_ATTR, clientID, HTML.ID_ATTR);
+        writer.writeAttribute(HTML.NAME_ATTR, clientID, HTML.NAME_ATTR);
+
+        String value = "";
+        Object objValue = ((UIInput) passwordStrength).getSubmittedValue();
+        if (objValue != null) {
+            value = passwordStrength.getValue().toString();
+        }
+        writer.writeAttribute("value", value, "value");
+
+        writer.writeAttribute("onkeyup", createOnKeyUpString(context,
+                passwordStrength, textID, preferredLength, prefixText,
+                textStrengthDescriptions, true, showDetails, useCustomSecurity,
+                customSecurityExpression, penaltyRatio), "onkeyup");
+        writer.writeAttribute("onblur", getOnBlurString(context, passwordStrength), "onblur");
+
+        writer.endElement(HTML.INPUT_ELEM);
+
+        writer.endElement(HTML.SPAN_ELEM);
+    }
+
+    
+    private void createTextIndicatorMessage(UIComponent component,
+            FacesContext context, ResponseWriter writer) throws IOException {
+        String clientID = component.getClientId(context);
+        
+        writer.startElement(HTML.SPAN_ELEM, component);
+        writer.writeAttribute(HTML.ID_ATTR, getIndicatorMessageId( clientID ),
+                HTML.ID_ATTR);
+        writer.writeAttribute(HTML.CLASS_ATTR, "indicatorMessage",
+                HTML.CLASS_ATTR);
+        writer.endElement(HTML.SPAN_ELEM);        
+    }
+    
+    private void createIndicatorSpan(UIComponent component,
+            FacesContext context, ResponseWriter writer) throws IOException {
+        PasswordStrengthComponent passwordStrength = (PasswordStrengthComponent) component;
+    
+        String clientID = passwordStrength.getClientId(context);
+        String strengthIndicatorType =     getStrengthIndicatorTypeValue(passwordStrength);
+
+        writer.endElement(HTML.TD_ELEM);
+        writer.startElement(HTML.TD_ELEM, component);
+
+        if(TextIndicatorType.TEXT.equalsIgnoreCase( strengthIndicatorType )) { //It is a text ...
+            createTextIndicatorMessage(component, context, writer);
+        } else { //It is a progressbar ...     
+            createProgressBarSpan(component, context, writer);
+        }
+
+        writer.endElement(HTML.TD_ELEM);
+        writer.endElement(HTML.TR_ELEM);
+
+        writer.startElement(HTML.TR_ELEM, component);
+        writer.startElement(HTML.TD_ELEM, component);
+
+        writer.startElement("div", component);
+        writer.writeAttribute("id", getleftCharsMessageId(clientID), "id");
+        writer.endElement("div");
+    }
+    
+    private String getStrengthIndicatorType(
+            PasswordStrengthComponent passwordStrength) {
+        return (passwordStrength.getStrengthIndicatorType() == null) ? "'"
+                + getDefaultStrengthIndicatorType() + "'" : "'"
+                + passwordStrength.getStrengthIndicatorType() + "'";
+    }
+
+    private String getStrengthIndicatorTypeValue(
+            PasswordStrengthComponent passwordStrength) {
+        return (passwordStrength.getStrengthIndicatorType() == null) ? getDefaultStrengthIndicatorType()
+                : passwordStrength.getStrengthIndicatorType();
+    }    
+    
+    private void createProgressBarSpan(UIComponent component,
+            FacesContext context, ResponseWriter writer) throws IOException {
+        String clientID = component.getClientId(context);
+
+        writer.startElement(HTML.SPAN_ELEM, component);        
+        writer.writeAttribute("id", getProgressBarContainerID(clientID), "id");    
+        
+        writer.startElement(HTML.SPAN_ELEM, component);
+        writer.writeAttribute("width", DEFAULT_PROGRESSBAR_WIDTH, "width");
+        writer.writeAttribute("height", DEFAULT_PROGRESSBAR_HEIGHT, "height");
+        writer.writeAttribute("progressValue", DEFAULT_PROGRESSBAR_VALUE, "progressValue");                
+        //writer.writeAttribute("hasText", "true", "hasText");
+        writer.writeAttribute("dojoType", "ProgressBar", "dojoType");        
+        writer.writeAttribute("id", getProgressBarID(clientID), "id");        
+        writer.endElement(HTML.SPAN_ELEM);
+        
+        writer.endElement(HTML.SPAN_ELEM);                
+    }
+
+    private void createHTMLComponents(FacesContext facesContext,
+            UIComponent component, ResponseWriter writer, String clientID)
+            throws IOException {
+        PasswordStrengthComponent passwordStrength = (PasswordStrengthComponent) component;
+
+        renderStartDiv(component, writer);
+
+        createTextSpan(passwordStrength, facesContext, clientID);
+
+        createIndicatorSpan(component, facesContext, writer);
+
+        renderEndDiv(component, writer);
+    }
+
+    public void encodeBegin(FacesContext context, UIComponent component)
+            throws IOException {
+        RendererUtils.checkParamValidity(context, component,
+                PasswordStrengthComponent.class);
+
+        if (HtmlRendererUtils.isDisplayValueOnly(component)
+                || isDisabled(context, component)) {
+            super.encodeEnd(context, component);
+            return;
+        }
+
+        String clientID = component.getClientId(context);
+
+        ResponseWriter writer = context.getResponseWriter();
+
+        addResources(context, component, writer);
+
+        createHTMLComponents(context, component, writer, clientID);
+    }
+
+    public void encodeEnd(FacesContext context, UIComponent component)
+            throws IOException {
+    }
+
+    public void decode(FacesContext context, UIComponent component) {
+        Map requestMap = context.getExternalContext().getRequestParameterMap();
+
+        String clientID = component.getClientId(context);
+
+        String newValue = (String) requestMap.get(clientID);
+
+        ((UIInput) component).setSubmittedValue(newValue);
+    }
+
+    protected boolean isDisabled(FacesContext facesContext,
+            UIComponent component) {
+        if (component instanceof HtmlInputText) {
+            return ((HtmlInputText) component).isDisabled();
+        } else {
+            return org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils
+                    .getBooleanAttribute(component, HTML.DISABLED_ATTR, false);
+        }
+    }
+
+    private String createOnKeyUpString(FacesContext context,
+            UIComponent component, String textID, String preferredLength,
+            String prefix, String textStrengthDescriptions,
+            boolean showMessageIndicator, String showDetails,
+            String useCustomSecurity, String customSecurityExpression,
+            String penaltyRatio) {
+        
+        PasswordStrengthComponent passwordStrength = (PasswordStrengthComponent) component;
+
+        String clientID = component.getClientId(context);
+        String showMessageIndicatorString = "";
+        String strengthIndicatorType = getStrengthIndicatorType(passwordStrength);
+        String progressBarId = "'" + getProgressBarID(clientID) + "'";
+        String indicatorMessageID = "'" + getIndicatorMessageId(clientID) + "'";
+        String leftCharsMessageID = "'" + getleftCharsMessageId(clientID) + "'";
+
+        if (showMessageIndicator == true) {
+            showMessageIndicatorString = "show('"
+                    + getMessageID(context, passwordStrength) + "');";
+        }
+
+        return updateStatusValue(textID, preferredLength, prefix,
+                textStrengthDescriptions, indicatorMessageID,
+                leftCharsMessageID, showMessageIndicatorString,
+                strengthIndicatorType, progressBarId, showDetails,
+                getLeftCharactersString(), useCustomSecurity,
+                customSecurityExpression, penaltyRatio);
+    }
+    
+    private String updateStatusValue(String textID, String preferredLength,
+                                     String prefix, String textStrengthDescriptions,
+                                     String indicatorMessageID, String leftCharsMessageID,                                     
+                                     String showMessageIndicatorString, 
+                                     String strengthIndicatorType, String progressBarId, 
+                                     String showDetails, String leftCharactersString,
+                                     String useCustomSecurity, String customSecurityExpression,
+                                     String penaltyRatio) {
+        return "updateStatusValue(" 
+                + textID + "," + preferredLength + ", "
+                + prefix + ", " + textStrengthDescriptions + ", " 
+                + indicatorMessageID + ", " + leftCharsMessageID + ", "                
+                + strengthIndicatorType + ", " + progressBarId + ", "                 
+                + showDetails + ", " + leftCharactersString + ", "     
+                + useCustomSecurity + ", " + customSecurityExpression + ", "
+                + penaltyRatio
+                + ");"            
+                + showMessageIndicatorString;
+    }
+    
+    private String getIndicatorMessageId(String clientID) {    
+        return clientID + "indicatorMessage";
+    }
+    
+    private String getleftCharsMessageId(String clientID) {    
+        return clientID + "leftCharsMessage";
+    }    
+
+    private String getProgressBarID(String clientID) {    
+        return clientID + PROGRESSBAR_SUFFIX;
+    }
+    
+    private String getProgressBarContainerID(String clientID) {    
+        return getProgressBarID(clientID) + PROGRESSBAR_CONTAINER_SUFFIX;
+    }            
+    
+    private String getOnBlurString(FacesContext context, UIComponent component) {
+        PasswordStrengthComponent passwordStrength = (PasswordStrengthComponent) component;        
+        String clientID = passwordStrength.getClientId(context);        
+        
+        return "hide('" + getMessageID(context, passwordStrength) + "');" + "hide('"
+                + getleftCharsMessageId(clientID) + "');";
+    }
+
+    final String BUNDLE_BASE_NAME = "org.apache.myfaces.custom.passwordStrength.resource.PasswordStrength";
+    final String DEFAULT_PROGRESSBAR_WIDTH = "150";
+    final String DEFAULT_PROGRESSBAR_HEIGHT = "20";    
+    final String PROGRESSBAR_SUFFIX = "_PROGRESSBAR";
+    final String PROGRESSBAR_CONTAINER_SUFFIX = "_CONTAINER";    
+    final String DEFAULT_PROGRESSBAR_VALUE = "20";
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/TextIndicatorType.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/TextIndicatorType.java?rev=673836&r1=673835&r2=673836&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/TextIndicatorType.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/TextIndicatorType.java Thu Jul  3 15:03:29 2008
@@ -1,24 +1,24 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.custom.passwordStrength;
-
-public interface TextIndicatorType {
-    public String PROGRESSBAR = "bar";
-    public String TEXT = "text";    
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.passwordStrength;
+
+public interface TextIndicatorType {
+    public String PROGRESSBAR = "bar";
+    public String TEXT = "text";    
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/TextIndicatorType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/ContextCallback.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRFacesContextWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRLifecycleFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRLifecycleWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitRenderer.java?rev=673836&r1=673835&r2=673836&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitRenderer.java Thu Jul  3 15:03:29 2008
@@ -1,126 +1,126 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.custom.ppr;
-
-import org.apache.commons.lang.StringUtils;
-
-import javax.faces.FacesException;
-import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.render.Renderer;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * If container for a commond component this component allows you to configure which components
- * to process (validate/update-model) during a ppr request.
- *
- * TODO: document why this component helps with UIData too ... why does it?
- * 
- * @JSFRenderer
- *   renderKitId = "HTML_BASIC" 
- *   family = "org.apache.myfaces.PPRSubmit"
- *   type = "org.apache.myfaces.PPRSubmit"
- * 
- */
-public class PPRSubmitRenderer extends Renderer
-{
-    public void encodeBegin(FacesContext context, UIComponent component) throws IOException
-    {
-        super.encodeBegin(context, component);
-
-        final PPRSubmit pprSubmit = (PPRSubmit) component;
-        UICommand command = findCommandComponent(false, component);
-        if (!StringUtils.isEmpty(pprSubmit.getProcessComponentIds()) &&
-            (command == null || command.isImmediate())) {
-            throw new FacesException("PPRSubmit must embed a command component with immedate='false'.");
-        }
-    }
-
-    public void encodeEnd(FacesContext context, UIComponent component) throws IOException
-    {
-        UICommand command = findCommandComponent(true, component);
-
-        if (command != null) {
-            List panelGroups = new ArrayList(5);
-            String id = command.getId();
-            addPPRPanelGroupComponents(context.getViewRoot(), panelGroups);
-            for (int i = 0; i < panelGroups.size(); i++) {
-                PPRPanelGroup pprGroup = (PPRPanelGroup) panelGroups.get(i);
-
-                if (!PPRSupport.isPartialRequest(context)) {
-                    PPRSupport.initPPR(context, pprGroup);
-                }
-
-                List triggers = pprGroup.parsePartialTriggers();
-                for (int j = 0; j < triggers.size(); j++) {
-                    PartialTriggerParser.PartialTrigger trigger = (PartialTriggerParser.PartialTrigger) triggers.get(j);
-
-                    // TODO: what about trigger patterns?
-                    if (trigger.getPartialTriggerId().equals(id)) {
-                        PPRSupport.encodeJavaScriptTriggerOnly(context, command, pprGroup, trigger);
-                    }
-                }
-            }
-        }
-        else {
-            throw new FacesException("PPRSubmitRenderer must be embedded in or embed a command component.");
-        }
-    }
-
-    /**
-     * This component can be child of a command component or embed one as child.
-     * Try to find the command component that way.
-     */
-    private UICommand findCommandComponent(boolean checkParent, UIComponent component)
-    {
-        if (checkParent) {
-            UIComponent parent = component.getParent();
-            if (parent instanceof UICommand) {
-                return (UICommand) parent;
-            }
-        }
-
-        if (component.getChildCount() > 0) {
-            UIComponent child = (UIComponent) component.getChildren().get(0);
-            if (child instanceof UICommand) {
-                return (UICommand) child;
-            }
-        }
-
-        return null;
-    }
-
-    public void addPPRPanelGroupComponents(UIComponent component, List list)
-    {
-        // TODO: what about facets?
-        for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
-            UIComponent c = (UIComponent) it.next();
-            if (c instanceof PPRPanelGroup) {
-                list.add(c);
-            }
-            if (c.getChildCount() > 0) {
-                addPPRPanelGroupComponents(c, list);
-            }
-        }
-    }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.ppr;
+
+import org.apache.commons.lang.StringUtils;
+
+import javax.faces.FacesException;
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.render.Renderer;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * If container for a commond component this component allows you to configure which components
+ * to process (validate/update-model) during a ppr request.
+ *
+ * TODO: document why this component helps with UIData too ... why does it?
+ * 
+ * @JSFRenderer
+ *   renderKitId = "HTML_BASIC" 
+ *   family = "org.apache.myfaces.PPRSubmit"
+ *   type = "org.apache.myfaces.PPRSubmit"
+ * 
+ */
+public class PPRSubmitRenderer extends Renderer
+{
+    public void encodeBegin(FacesContext context, UIComponent component) throws IOException
+    {
+        super.encodeBegin(context, component);
+
+        final PPRSubmit pprSubmit = (PPRSubmit) component;
+        UICommand command = findCommandComponent(false, component);
+        if (!StringUtils.isEmpty(pprSubmit.getProcessComponentIds()) &&
+            (command == null || command.isImmediate())) {
+            throw new FacesException("PPRSubmit must embed a command component with immedate='false'.");
+        }
+    }
+
+    public void encodeEnd(FacesContext context, UIComponent component) throws IOException
+    {
+        UICommand command = findCommandComponent(true, component);
+
+        if (command != null) {
+            List panelGroups = new ArrayList(5);
+            String id = command.getId();
+            addPPRPanelGroupComponents(context.getViewRoot(), panelGroups);
+            for (int i = 0; i < panelGroups.size(); i++) {
+                PPRPanelGroup pprGroup = (PPRPanelGroup) panelGroups.get(i);
+
+                if (!PPRSupport.isPartialRequest(context)) {
+                    PPRSupport.initPPR(context, pprGroup);
+                }
+
+                List triggers = pprGroup.parsePartialTriggers();
+                for (int j = 0; j < triggers.size(); j++) {
+                    PartialTriggerParser.PartialTrigger trigger = (PartialTriggerParser.PartialTrigger) triggers.get(j);
+
+                    // TODO: what about trigger patterns?
+                    if (trigger.getPartialTriggerId().equals(id)) {
+                        PPRSupport.encodeJavaScriptTriggerOnly(context, command, pprGroup, trigger);
+                    }
+                }
+            }
+        }
+        else {
+            throw new FacesException("PPRSubmitRenderer must be embedded in or embed a command component.");
+        }
+    }
+
+    /**
+     * This component can be child of a command component or embed one as child.
+     * Try to find the command component that way.
+     */
+    private UICommand findCommandComponent(boolean checkParent, UIComponent component)
+    {
+        if (checkParent) {
+            UIComponent parent = component.getParent();
+            if (parent instanceof UICommand) {
+                return (UICommand) parent;
+            }
+        }
+
+        if (component.getChildCount() > 0) {
+            UIComponent child = (UIComponent) component.getChildren().get(0);
+            if (child instanceof UICommand) {
+                return (UICommand) child;
+            }
+        }
+
+        return null;
+    }
+
+    public void addPPRPanelGroupComponents(UIComponent component, List list)
+    {
+        // TODO: what about facets?
+        for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
+            UIComponent c = (UIComponent) it.next();
+            if (c instanceof PPRPanelGroup) {
+                list.add(c);
+            }
+            if (c.getChildCount() > 0) {
+                addPPRPanelGroupComponents(c, list);
+            }
+        }
+    }
 }
\ No newline at end of file

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRSubmitRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native