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/05 11:52:40 UTC

svn commit: r471395 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/component/ core/src/main/java/org/apache/myfaces/tobago/renderkit/html/ core/src/main/java/org/apache/myfaces/tobago/taglib/component/ theme/scarborough/src/ma...

Author: bommel
Date: Sun Nov  5 02:52:39 2006
New Revision: 471395

URL: http://svn.apache.org/viewvc?view=rev&rev=471395
Log:
add markup support for box

Added:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIBox.java
Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/BoxTag.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/BoxTagDeclaration.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
    myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java

Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIBox.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIBox.java?view=auto&rev=471395
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIBox.java (added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIBox.java Sun Nov  5 02:52:39 2006
@@ -0,0 +1,68 @@
+package org.apache.myfaces.tobago.component;
+
+/*
+ * Copyright 2002-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MARKUP;
+
+import javax.faces.el.ValueBinding;
+import javax.faces.context.FacesContext;
+
+/*
+ * Created by IntelliJ IDEA.
+ * User: bommel
+ * Date: Nov 4, 2006
+ * Time: 3:10:46 PM
+ */
+public class UIBox extends UIPanel
+    implements SupportsMarkup {
+
+  public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Box";
+
+  private String markup;
+
+  public String getMarkup() {
+    if (markup != null) {
+      return markup;
+    }
+    ValueBinding vb = getValueBinding(ATTR_MARKUP);
+    if (vb != null) {
+      return (String) vb.getValue(getFacesContext());
+    } else {
+      return null;
+    }
+  }
+
+  public void setMarkup(String markup) {
+    this.markup = markup;
+  }
+
+  @Override
+  public void restoreState(FacesContext context, Object state) {
+    Object[] values = (Object[]) state;
+    super.restoreState(context, values[0]);
+    markup = (String) values[1];
+   }
+
+  @Override
+  public Object saveState(FacesContext context) {
+    Object[] values  = new Object[2];
+    values[0] = super.saveState(context);
+    values[1] = markup;
+    return values;
+  }
+
+}

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=471395&r1=471394&r2=471395
==============================================================================
--- 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 Sun Nov  5 02:52:39 2006
@@ -440,20 +440,24 @@
     if (ComponentUtil.isError(component)) {
       tobagoClass.append(prefix).append(TOBAGO_CSS_CLASS_SUFFIX_ERROR);
     }
+    addMarkupClass(component, rendererName, tobagoClass);
+    return tobagoClass.append(cssClass).toString();
+  }
+
+  public static void addMarkupClass(UIComponent component, String rendererName, StringBuffer tobagoClass) {
 
     if (component instanceof SupportsMarkup) {
       String markup = ComponentUtil.getStringAttribute(component, ATTR_MARKUP);
       if (StringUtils.isNotEmpty(markup)) {
         Theme theme = ClientProperties.getInstance(FacesContext.getCurrentInstance().getViewRoot()).getTheme();
         if (theme.getRenderersConfig().isMarkupSupported(rendererName, markup)) {
-          tobagoClass.append(prefix).append("-markup-").append(markup).append(" ");
+          tobagoClass.append(TOBAGO_CSS_CLASS_PREFIX).append(rendererName)
+              .append("-markup-").append(markup).append(" ");
         } else {
           LOG.warn("Unknown markup='" + markup + "'");
         }
       }
     }
-
-    return tobagoClass.append(cssClass).toString();
   }
 
   public static void addImageSources(

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/BoxTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/BoxTag.java?view=diff&rev=471395&r1=471394&r2=471395
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/BoxTag.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/BoxTag.java Sun Nov  5 02:52:39 2006
@@ -16,9 +16,12 @@
  * limitations under the License.
  */
 
-import org.apache.myfaces.tobago.component.UIPanel;
+import org.apache.myfaces.tobago.component.ComponentUtil;
+import org.apache.myfaces.tobago.component.UIBox;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MARKUP;
 
 import javax.servlet.jsp.tagext.BodyTag;
+import javax.faces.component.UIComponent;
 
 /**
  * Renders a panel with border and title.
@@ -27,8 +30,24 @@
 public class BoxTag extends TobagoBodyTag
     implements BodyTag, BoxTagDeclaration {
 
+  private String markup;
+
   public String getComponentType() {
-    return UIPanel.COMPONENT_TYPE;
+    return UIBox.COMPONENT_TYPE;
+  }
+
+  public void release() {
+    super.release();
+    markup = null;
+  }
+
+  protected void setProperties(UIComponent component) {
+    super.setProperties(component);
+    ComponentUtil.setStringProperty(component, ATTR_MARKUP, markup);
+  }
+
+  public void setMarkup(String markup) {
+    this.markup = markup;
   }
 }
 

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/BoxTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/BoxTagDeclaration.java?view=diff&rev=471395&r1=471394&r2=471395
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/BoxTagDeclaration.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/BoxTagDeclaration.java Sun Nov  5 02:52:39 2006
@@ -18,6 +18,8 @@
 
 import org.apache.myfaces.tobago.apt.annotation.Tag;
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
+import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
+import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
 import org.apache.myfaces.tobago.taglib.decl.HasDeprecatedDimension;
 import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
 import org.apache.myfaces.tobago.taglib.decl.HasLabel;
@@ -27,9 +29,17 @@
  */
 @Tag(name = "box")
 @UIComponentTag(
-    uiComponent = "org.apache.myfaces.tobago.component.UIPanel",
+    uiComponent = "org.apache.myfaces.tobago.component.UIBox",
     rendererType = "Box")
 
 public interface BoxTagDeclaration extends TobagoBodyTagDeclaration,
     HasIdBindingAndRendered, HasDeprecatedDimension, HasLabel {
+
+  /**
+   * Indicate markup of this component.
+   * Possible value is 'none'. But this can be overridden in the theme.
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(defaultValue = "none")
+  void setMarkup(String markup);
 }

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?view=diff&rev=471395&r1=471394&r2=471395
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Sun Nov  5 02:52:39 2006
@@ -356,15 +356,21 @@
         if (align != null) {
           tdStyle = "text-align: " + align;
         }
-        final String cellClass = (String) column.getAttributes().get(
-            ATTR_STYLE_CLASS);
-        final String tdClass = "tobago-sheet-cell-td "
-            + (cellClass != null ? cellClass : "");
+        final String cellClass = (String) column.getAttributes().get(ATTR_STYLE_CLASS);
 
+        final StringBuffer tdClass = new StringBuffer();
+        tdClass.append("tobago-sheet-cell-td ");
+        HtmlRendererUtil.addMarkupClass(column, "sheet-cell", tdClass);
+        if (columnIndex == 0) {
+          tdClass.append("tobago-sheet-cell-first-column ");
+        }
+        if (cellClass !=null) {
+          tdClass.append(cellClass);
+        }
 
         writer.startElement(HtmlConstants.TD, column);
 
-        writer.writeClassAttribute(tdClass);
+        writer.writeClassAttribute(tdClass.toString());
         writer.writeAttribute(HtmlAttributes.STYLE, tdStyle, null);
 
         writer.startElement(HtmlConstants.DIV, null);
@@ -1075,8 +1081,9 @@
     final String ajaxId = (String) facesContext.getExternalContext()
         .getRequestParameterMap().get(AjaxPhaseListener.AJAX_COMPONENT_ID);
     if (ajaxId.equals(component.getClientId(facesContext))) {
-      if (component.getFacet("reload") != null && component.getFacet("reload") instanceof UIReload) {
-        UIReload reload = (UIReload) component.getFacet("reload");
+      if (component.getFacet(FACET_RELOAD) != null && component.getFacet(FACET_RELOAD) instanceof UIReload
+          && component.getFacet(FACET_RELOAD).isRendered()) {
+        UIReload reload = (UIReload) component.getFacet(FACET_RELOAD);
         update = reload.getUpdate();
       }
     }

Modified: myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java?view=diff&rev=471395&r1=471394&r2=471395
==============================================================================
--- myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java (original)
+++ myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java Sun Nov  5 02:52:39 2006
@@ -77,7 +77,6 @@
     }
 
     String clientId = component.getClientId(facesContext);
-
     writer.startElement(HtmlConstants.DIV, component);
     writer.writeComponentClass();
     writer.writeIdAttribute(clientId);