You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2006/11/28 21:50:10 UTC

svn commit: r480201 - in /myfaces/tobago/trunk: ./ core/src/main/java/org/apache/myfaces/tobago/ core/src/main/java/org/apache/myfaces/tobago/renderkit/html/ theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/...

Author: bommel
Date: Tue Nov 28 12:50:08 2006
New Revision: 480201

URL: http://svn.apache.org/viewvc?view=rev&rev=480201
Log:
TOBAGO-201 Added required image style for tc:date and tc:in
TOBAGO-65 Wrong class attributes in tc:date and tx:date

Added:
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/required.gif   (with props)
Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java
    myfaces/tobago/trunk/pom.xml
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/calendar.js
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css
    myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/style.css
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java?view=diff&rev=480201&r1=480200&r2=480201
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java Tue Nov 28 12:50:08 2006
@@ -77,7 +77,7 @@
   public static final String ATTR_MARGIN_RIGHT = "marginRight";
   public static final String ATTR_MARGIN_TOP = "marginTop";
   public static final String ATTR_LAYOUT_ORDER = "layoutOrder";
-  public static final String ATTR_LAYOUT_TABLE_STYLE = "layoutTableStyle";
+  //public static final String ATTR_LAYOUT_TABLE_STYLE = "layoutTableStyle";
   public static final String ATTR_LAYOUT_WIDTH = "layoutWidth";
   public static final String ATTR_LEFT = "left";
   public static final String ATTR_MARKUP = "markup";
@@ -221,7 +221,7 @@
   public static final String TOBAGO_CSS_CLASS_SUFFIX_READONLY = "-readonly ";
   public static final String TOBAGO_CSS_CLASS_SUFFIX_INLINE = "-inline ";
   public static final String TOBAGO_CSS_CLASS_SUFFIX_ERROR = "-error ";
-  public static final String TOBAGO_CSS_CLASS_SUFFIX_REQUIRED = "-required";
+  public static final String TOBAGO_CSS_CLASS_SUFFIX_REQUIRED = "-required ";
 
   private TobagoConstants() {
     // to prevent instantiation

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java?view=diff&rev=480201&r1=480200&r2=480201
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java Tue Nov 28 12:50:08 2006
@@ -132,6 +132,14 @@
 
   }
 
+  public static String getRendererName(FacesContext facesContext, UIComponent component) {
+    final String rendererType = component.getRendererType();
+    if (rendererType != null) {
+      return ComponentUtil.getRenderer(facesContext, component).getRendererName(rendererType);
+    }
+    return null;
+  }
+
   public static void writeLabelWithAccessKey(ResponseWriter writer,
       LabelWithAccessKey label)
       throws IOException {

Modified: myfaces/tobago/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/pom.xml?view=diff&rev=480201&r1=480200&r2=480201
==============================================================================
--- myfaces/tobago/trunk/pom.xml (original)
+++ myfaces/tobago/trunk/pom.xml Tue Nov 28 12:50:08 2006
@@ -171,7 +171,16 @@
     <excludeDefaults>true</excludeDefaults>
     <plugins>
 
-     <plugin>
+      <!--<plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>simian-report-maven-plugin</artifactId>
+        <version>1.0-SNAPSHOT</version>
+        <configuration>
+          <minimumThreshold>2</minimumThreshold>
+        </configuration>
+      </plugin>
+      -->
+      <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>cobertura-maven-plugin</artifactId>
       </plugin>

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java?view=diff&rev=480201&r1=480200&r2=480201
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java Tue Nov 28 12:50:08 2006
@@ -24,7 +24,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE_CLASS;
 import org.apache.myfaces.tobago.component.ComponentUtil;
 import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
@@ -60,9 +59,6 @@
       HtmlRendererUtil.writeScriptLoader(facesContext, scripts, null);
     }
 
-    String classes = ComponentUtil.getStringAttribute(component, ATTR_STYLE_CLASS);
-    classes = classes.replaceAll("tobago-date-", "tobago-in-");
-    component.getAttributes().put(ATTR_STYLE_CLASS, classes);
     super.encodeEnd(facesContext, component);
 
     Converter help = getConverter(facesContext, component);
@@ -87,6 +83,7 @@
     }
 
     // focus
+    // TODO is this not already done in InRenderer?
     HtmlRendererUtil.renderFocusId(facesContext, component);
   }
 }

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java?view=diff&rev=480201&r1=480200&r2=480201
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java Tue Nov 28 12:50:08 2006
@@ -24,12 +24,16 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import static org.apache.myfaces.tobago.TobagoConstants.TOBAGO_CSS_CLASS_PREFIX;
+import static org.apache.myfaces.tobago.TobagoConstants.TOBAGO_CSS_CLASS_SUFFIX_REQUIRED;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_PASSWORD;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_READONLY;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE_CLASS;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
 import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_REQUIRED;
 import org.apache.myfaces.tobago.ajax.api.AjaxPhaseListener;
 import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
 import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
@@ -41,6 +45,7 @@
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
+import org.apache.myfaces.tobago.TobagoConstants;
 
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIComponent;
@@ -58,8 +63,7 @@
   private static final Log LOG = LogFactory.getLog(InRenderer.class);
 
   @Override
-  public void encodeEnd(FacesContext facesContext,
-        UIComponent component)
+  public void encodeEnd(FacesContext facesContext, UIComponent component)
         throws IOException {
     Iterator messages = facesContext.getMessages(
         component.getClientId(facesContext));
@@ -91,7 +95,6 @@
           ((org.apache.myfaces.tobago.component.UIInput) component).getSuggestMethod() != null;
     }
 
-
     String id = component.getClientId(facesContext);
     TobagoResponseWriter writer = (TobagoResponseWriter)
         facesContext.getResponseWriter();
@@ -123,6 +126,14 @@
     writer.writeAttribute(HtmlAttributes.DISABLED,
         ComponentUtil.getBooleanAttribute(component, ATTR_DISABLED));
     writer.writeAttribute(HtmlAttributes.STYLE, null, ATTR_STYLE);
+    
+    if (currentValue != null && currentValue.length() > 0
+        && ComponentUtil.getBooleanAttribute(component, ATTR_REQUIRED)) {
+      String classes = ComponentUtil.getStringAttribute(component, ATTR_STYLE_CLASS);
+      String rendererName = HtmlRendererUtil.getRendererName(facesContext, component);
+      classes = classes.replaceAll(TOBAGO_CSS_CLASS_PREFIX+rendererName+TOBAGO_CSS_CLASS_SUFFIX_REQUIRED, "");
+      component.getAttributes().put(ATTR_STYLE_CLASS, classes);
+    }
     writer.writeComponentClass();
     if (renderAjaxSuggest) {
       writer.writeAttribute(HtmlAttributes.AUTOCOMPLETE, "off", false);
@@ -136,6 +147,15 @@
     }
     writer.endElement(HtmlConstants.INPUT);
 
+    if (ComponentUtil.getBooleanAttribute(component, ATTR_REQUIRED)) {
+      String rendererName = HtmlRendererUtil.getRendererName(facesContext, component);
+      final String[] cmds = {
+         "new Tobago.In(\"" + id + "\", true ,\"" + TobagoConstants.TOBAGO_CSS_CLASS_PREFIX + rendererName + "\"  );"
+      };
+
+      HtmlRendererUtil.writeScriptLoader(facesContext, null, cmds);
+    }
+
     // focus
     HtmlRendererUtil.renderFocusId(facesContext, component);
 
@@ -217,6 +237,5 @@
     writer.endElement(HtmlConstants.UL);
     context.responseComplete();
   }
-
 }
 

Added: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/required.gif
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/required.gif?view=auto&rev=480201
==============================================================================
Binary file - no diff available.

Propchange: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/required.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/calendar.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/calendar.js?view=diff&rev=480201&r1=480200&r2=480201
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/calendar.js (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/calendar.js Tue Nov 28 12:50:08 2006
@@ -261,6 +261,7 @@
   }
   var date = new Date(year, month - 1, day, hour, minute, second);
   textBox.value = formatDate(date, document.calendar.formatPattern);
+  textBox.focus();
 //  alert(document.calendar.formatPattern);
 }
 

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css?view=diff&rev=480201&r1=480200&r2=480201
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css Tue Nov 28 12:50:08 2006
@@ -649,6 +649,12 @@
   text-align: right;
 }
 
+.tobago-in-required {
+   background-image: url( "../image/required.gif" );
+   background-position: 3px 50%;
+   background-repeat: no-repeat;
+}
+
 .tobago-in-readonly  {
   background: #bbccdd;
 }
@@ -689,6 +695,40 @@
   padding:0px;
 }
 
+
+/* date ---------------------------------------------------------------------- */
+
+.tobago-date-default  {
+  font-family: arial, helvetica, sans-serif;
+  background: #ffffff;
+  height: 25px;
+  color: #000000;
+  border-color: #bbccdd;
+  border-style: inset;
+  border-width: 2px;
+  margin: 0px;
+}
+
+
+.tobago-date-required {
+   background-image: url( "../image/required.gif" );
+   background-position: 3px 50%;
+   background-repeat: no-repeat;
+}
+
+.tobago-date-readonly  {
+  background: #bbccdd;
+}
+
+.tobago-date-disabled  {
+  color: #778899;
+  background: #bbccdd;
+}
+
+.tobago-date-error  {
+  border-style: solid;
+  border-color: #ff0000;
+}
 /* end --------------------------------------------------------------------- */
 
 .tobago-input-picker {

Modified: myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/style.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/style.css?view=diff&rev=480201&r1=480200&r2=480201
==============================================================================
--- myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/style.css (original)
+++ myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/style.css Tue Nov 28 12:50:08 2006
@@ -506,6 +506,30 @@
 }
 
 
+/* date ---------------------------------------------------------------------- */
+
+.tobago-date-default  {
+  border: 1px #000000 solid;
+  height: 20px;
+  font: 12px arial, helvetica, sans-serif;
+  padding-left: 2px;
+  padding-right: 2px;
+}
+
+.tobago-date-readonly  {
+  background-color: #E8E8E8;
+}
+
+.tobago-date-disabled  {
+  color: #808080;
+  background-color: #E8E8E8;
+}
+
+.tobago-date-error {
+  border: 1px solid #FF0000;
+}
+
+
 /* selectOneChoice --------------------------------------------------------- */
 
 .tobago-selectOneChoice-default  {

Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?view=diff&rev=480201&r1=480200&r2=480201
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Tue Nov 28 12:50:08 2006
@@ -224,11 +224,10 @@
     TbgTimer.endAppOnload = new Date();
 
     this.loadPngFix();
-    this.setFocus();
 
     this.addBindEventListener(document, "keypress", this.acceleratorKeys, "observe");
 
-    window.setTimeout(Tobago.finishPageLoading, 10);
+    window.setTimeout(Tobago.finishPageLoading, 1);
     TbgTimer.endOnload = new Date();
   },
 
@@ -238,6 +237,7 @@
     Tobago.startScriptLoaders();
     TbgTimer.endScriptLoaders = new Date();
     Tobago.pageIsComplete = true;
+    Tobago.setFocus();
     TbgTimer.endTotal = new Date();
     TbgTimer.log();
   },
@@ -1302,6 +1302,34 @@
   this.disabled = disabled;
   this.hover = hover;
   Tobago.images[id] = this;
+};
+
+Tobago.In = function(inId, required, cssPrefix) {
+  this.id = inId;
+  this.required = required;
+  this.cssPrefix = cssPrefix;
+  if (required) {
+    var ctrl = Tobago.element(this.id);
+    if (ctrl.value && ctrl.value.length > 0) {
+      Tobago.removeCssClass(id, cssPrefix + "-required" );
+    }
+    Tobago.addBindEventListener(ctrl, "focus", this, "enterRequired");
+    Tobago.addBindEventListener(ctrl, "blur", this, "leaveRequired");
+  }
+};
+
+Tobago.In.prototype.enterRequired = function(e) {
+  var evt = e || window.event;
+  var ctrl = evt.target || evt.srcElement;
+  Tobago.removeCssClass(ctrl.id, this.cssPrefix + "-required");
+};
+
+Tobago.In.prototype.leaveRequired = function (e) {
+  var evt = e || window.event;
+  var ctrl = evt.target || evt.srcElement;
+  if (!ctrl.value || ctrl.value.length == 0) {
+    Tobago.addCssClass(ctrl.id, this.cssPrefix + "-required");
+  }
 };
 
 Tobago.Panel = function(panelId, enableAjax, autoReload) {