myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r743740 - in /myfaces/tobago/branches/tobago-1.0.x: ./ core/src/main/java/org/apache/myfaces/tobago/context/ core/src/test/java/org/apache/myfaces/tobago/context/ example/demo/src/main/webapp/WEB-INF/ example/demo/src/main/webapp/overview/ ...
Date Thu, 12 Feb 2009 13:56:36 GMT
Author: bommel
Date: Thu Feb 12 13:56:34 2009
New Revision: 743740

URL: http://svn.apache.org/viewvc?rev=743740&view=rev
Log:
Merged revisions 743495,743667,743675,743708 via svnmerge from 
https://svn.apache.org/repos/asf/myfaces/tobago/trunk

........
  r743495 | bommel | 2009-02-11 21:38:52 +0100 (Mi, 11 Feb 2009) | 3 lines
  
  (TOBAGO-626) Input length restriction for tc:textarea
  
  Start with a implementation based on the trinidad javascript
........
  r743667 | bommel | 2009-02-12 10:32:40 +0100 (Do, 12 Feb 2009) | 1 line
  
  (TOBAGO-626) Input length restriction for tc:textarea
........
  r743675 | bommel | 2009-02-12 11:03:33 +0100 (Do, 12 Feb 2009) | 1 line
  
  (TOBAGO-626) Input length restriction for tc:textarea
........
  r743708 | bommel | 2009-02-12 13:47:16 +0100 (Do, 12 Feb 2009) | 1 line
  
  (TOBAGO-626) Input length restriction for tc:textarea
........

Modified:
    myfaces/tobago/branches/tobago-1.0.x/   (props changed)
    myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/context/ResourceUtils.java
  (props changed)
    myfaces/tobago/branches/tobago-1.0.x/core/src/test/java/org/apache/myfaces/tobago/context/ResourceUtilsUnitTest.java
  (props changed)
    myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/WEB-INF/web.xml
    myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/overview/basic.jsp
    myfaces/tobago/branches/tobago-1.0.x/example/portlet/   (props changed)
    myfaces/tobago/branches/tobago-1.0.x/example/sandbox/src/main/webapp/feather-leaf.png
  (props changed)
    myfaces/tobago/branches/tobago-1.0.x/example/sandbox/src/main/webapp/feather-open.png
  (props changed)
    myfaces/tobago/branches/tobago-1.0.x/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon-leaf.gif
  (props changed)
    myfaces/tobago/branches/tobago-1.0.x/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon-open.gif
  (props changed)
    myfaces/tobago/branches/tobago-1.0.x/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon.gif
  (props changed)
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextAreaRenderer.java
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon-leaf.gif
  (props changed)
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon-open.gif
  (props changed)
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon.gif
  (props changed)
    myfaces/tobago/branches/tobago-1.0.x/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon-leaf.gif
  (props changed)
    myfaces/tobago/branches/tobago-1.0.x/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon-open.gif
  (props changed)
    myfaces/tobago/branches/tobago-1.0.x/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon.gif
  (props changed)
    myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Propchange: myfaces/tobago/branches/tobago-1.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -1 +1 @@
-/myfaces/tobago/trunk:699460,699891-700092
+/myfaces/tobago/trunk:699460,699891-700092,743495-743708

Propchange: myfaces/tobago/branches/tobago-1.0.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Propchange: myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/context/ResourceUtils.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -0,0 +1 @@
+/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceUtils.java:743495-743708

Propchange: myfaces/tobago/branches/tobago-1.0.x/core/src/test/java/org/apache/myfaces/tobago/context/ResourceUtilsUnitTest.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -0,0 +1 @@
+/myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/context/ResourceUtilsUnitTest.java:743495-743708

Modified: myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/WEB-INF/web.xml?rev=743740&r1=743739&r2=743740&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/WEB-INF/web.xml Thu
Feb 12 13:56:34 2009
@@ -29,6 +29,11 @@
     <param-value>true</param-value>
   </context-param>
 
+  <context-param>
+    <param-name>javax.faces.PARTIAL_STATE_SAVING_METHOD</param-name>
+    <param-value>false</param-value>
+  </context-param>  
+
   <filter>
     <filter-name>multipartFormdataFilter</filter-name>
     <filter-class>org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter</filter-class>

Modified: myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/overview/basic.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/overview/basic.jsp?rev=743740&r1=743739&r2=743740&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/overview/basic.jsp (original)
+++ myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/overview/basic.jsp Thu
Feb 12 13:56:34 2009
@@ -67,7 +67,9 @@
         </tc:panel>
 
         <tx:textarea value="#{overviewController.basicArea}" tabIndex="2"
-          label="#{overviewBundle.basic_textareaLabel}" />
+            label="#{overviewBundle.basic_textareaLabel}" >
+          <f:validateLength maximum="10" />
+        </tx:textarea>
       </tc:panel>
 
       <%-- row --%>

Propchange: myfaces/tobago/branches/tobago-1.0.x/example/portlet/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -0,0 +1 @@
+/myfaces/tobago/trunk/example/portlet:743495-743708

Propchange: myfaces/tobago/branches/tobago-1.0.x/example/sandbox/src/main/webapp/feather-leaf.png
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -0,0 +1 @@
+/myfaces/tobago/trunk/example/sandbox/src/main/webapp/feather-leaf.png:743495-743708

Propchange: myfaces/tobago/branches/tobago-1.0.x/example/sandbox/src/main/webapp/feather-open.png
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -0,0 +1 @@
+/myfaces/tobago/trunk/example/sandbox/src/main/webapp/feather-open.png:743495-743708

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon-leaf.gif
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -1 +1,2 @@
 /myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/new.gif:699460,699891-700092
+/myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon-leaf.gif:743495-743708

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon-open.gif
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -1 +1,2 @@
 /myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/openfoldericon.gif:699460,699891-700092
+/myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon-open.gif:743495-743708

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon.gif
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -1 +1,2 @@
 /myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/foldericon.gif:699460,699891-700092
+/myfaces/tobago/trunk/theme/richmond/src/main/resources/org/apache/myfaces/tobago/renderkit/html/richmond/standard/image/treeNode-icon.gif:743495-743708

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextAreaRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextAreaRenderer.java?rev=743740&r1=743739&r2=743740&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextAreaRenderer.java
(original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextAreaRenderer.java
Thu Feb 12 13:56:34 2009
@@ -34,10 +34,14 @@
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
+import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
+import org.apache.myfaces.tobago.TobagoConstants;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.LengthValidator;
 import java.io.IOException;
 
 public class TextAreaRenderer extends InputRendererBase {
@@ -93,6 +97,22 @@
     writer.endElement(HtmlConstants.TEXTAREA);
 
     checkForCommandFacet(input, facesContext, writer);
+    int maxLength = -1;
+    for (Validator validator : input.getValidators()) {
+      if (validator instanceof LengthValidator) {
+        LengthValidator lengthValidator = (LengthValidator) validator;
+        maxLength = lengthValidator.getMaximum();
+      }
+    }
+    boolean required = ComponentUtil.getBooleanAttribute(input, TobagoConstants.ATTR_REQUIRED);
+    if (required || maxLength > 0) {
+      String rendererName = HtmlRendererUtil.getRendererName(facesContext, input);
+      final String[] cmds = {
+          "new Tobago.In(\"" + input.getClientId(facesContext) + "\", true ,\""
+                  + StyleClasses.PREFIX + rendererName + "\" " + (maxLength > -1? ","
+ maxLength: "")  + "  );"
+      };
+      HtmlRendererUtil.writeScriptLoader(facesContext, null, cmds);
+    }
 
     // focus
     HtmlRendererUtil.renderFocusId(facesContext, component);

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon-leaf.gif
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -1 +1,2 @@
 /myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/new.gif:699460,699891-700092
+/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon-leaf.gif:743495-743708

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon-open.gif
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -1 +1,2 @@
 /myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/openfoldericon.gif:699460,699891-700092
+/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon-open.gif:743495-743708

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon.gif
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -1 +1,2 @@
 /myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/foldericon.gif:699460,699891-700092
+/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/treeNode-icon.gif:743495-743708

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon-leaf.gif
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -1 +1,2 @@
 /myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/new.gif:699460,699891-700092
+/myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon-leaf.gif:743495-743708

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon-open.gif
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -1 +1,2 @@
 /myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/openfoldericon.gif:699460,699891-700092
+/myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon-open.gif:743495-743708

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon.gif
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 12 13:56:34 2009
@@ -1 +1,2 @@
 /myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/foldericon.gif:699460,699891-700092
+/myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/treeNode-icon.gif:743495-743708

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=743740&r1=743739&r2=743740&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
(original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Thu Feb 12 13:56:34 2009
@@ -1723,18 +1723,77 @@
   Tobago.images[id] = this;
 };
 
-Tobago.In = function(inId, required, cssPrefix) {
+Tobago.In = function(inId, required, cssPrefix, maxLength) {
   this.id = inId;
   this.required = required;
   this.cssPrefix = cssPrefix;
-  if (required) {
+  this.maxLength = maxLength;
+  this.setup();
+};
+
+Tobago.In.prototype.setup = function() {
+  if (this.required) {
     var ctrl = Tobago.element(this.id);
     if (ctrl.value && ctrl.value.length > 0) {
-      Tobago.removeCssClass(this.id, cssPrefix + "-required" );
+      Tobago.removeCssClass(this.id, this.cssPrefix + "-required" );
     }
     Tobago.addBindEventListener(ctrl, "focus", this, "enterRequired");
     Tobago.addBindEventListener(ctrl, "blur", this, "leaveRequired");
   }
+  if (this.maxLength && this.maxLength > 0) {
+    var ctrl = Tobago.element(this.id);
+    Tobago.addBindEventListener(ctrl, "change", this, "checkMaxLength");
+    Tobago.addBindEventListener(ctrl, "keyup", this, "checkMaxLength");
+  }
+};
+
+Tobago.In.prototype.checkMaxLength = function(event) {
+  if (!event) {
+    event = window.event;
+  }
+  var ctrl = Tobago.element(this.id);
+  var elementLength = ctrl.value.length;
+  if (elementLength > this.maxLength) {
+    // Input is longer than max, truncate and return false.
+    // This takes care of the case where the user has pasted in text
+    // that's too long. Return true here because the onChange event can
+    // continue (now that we've truncated the value). This allows chained
+    // handlers to work.
+    ctrl.value = ctrl.value.substr(0, this.maxLength);
+    return true;
+  }
+
+  // If less than max length (i.e. within acceptable range), return true
+  if (elementLength < this.maxLength) {
+    return true;
+  }
+
+  // If we've made it to here, we know that elementLength == length
+
+  // If this is a change event, the field has already been updated to a string
+  // of the maximum allowable length. This is fine. Continue processing.
+  if (event.type == 'change') {
+    return true;
+  }
+
+  // If we've made it to here, we know that this is a keyPress event
+
+  // If the input is something less than a space (e.g. tab, CR, etc.)
+  // return true.
+  // If key was CTRL-v, which will be used to paste some new text,
+  // pass it along.
+  if (event) {
+    if ((event.which < 32)
+        || ((event.which == 118) && (event["ctrlKey"]))) {
+      return true;
+    }
+  }
+
+  // Default return FALSE. If we're here, this is an onKeyPress event, it's a
+  // printable character, and elementLength already equals the maximum allowed.
+  // We need to return false here to cancel the event otherwise this last
+  // character will end up in the input field in position MAX+1.
+  return false;
 };
 
 Tobago.In.prototype.enterRequired = function(e) {



Mime
View raw message