myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdud...@apache.org
Subject cvs commit: incubator-myfaces/conf faces-config.xml
Date Mon, 08 Nov 2004 03:43:20 GMT
bdudney     2004/11/07 19:43:20

  Modified:    src/share/org/apache/myfaces/renderkit/html HTML.java
               src/myfaces/org/apache/myfaces/el VariableResolverImpl.java
               tlds     myfaces_ext.tld
               conf     faces-config.xml
  Added:       src/components/org/apache/myfaces/custom/div Div.java
                        DivTag.java DivRenderer.java
  Log:
  Added a div element. x:div to use, inserts a div with class or style attributes
  
  Revision  Changes    Path
  1.14      +6 -2      incubator-myfaces/src/share/org/apache/myfaces/renderkit/html/HTML.java
  
  Index: HTML.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/share/org/apache/myfaces/renderkit/html/HTML.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- HTML.java	13 Oct 2004 11:51:01 -0000	1.13
  +++ HTML.java	8 Nov 2004 03:43:20 -0000	1.14
  @@ -24,6 +24,9 @@
    * @author Anton Koinov
    * @version $Revision$ $Date$
    * $Log$
  + * Revision 1.14  2004/11/08 03:43:20  bdudney
  + * Added a div element. x:div to use, inserts a div with class or style attributes
  + *
    * Revision 1.13  2004/10/13 11:51:01  matze
    * renamed packages to org.apache
    *
  @@ -415,6 +418,7 @@
   
       //HTML element constants
       public static final String SPAN_ELEM = "span";
  +    public static final String DIV_ELEM = "div";
       public static final String INPUT_ELEM = "input";
       public static final String SELECT_ELEM = "select";
       public static final String OPTION_ELEM = "option";
  
  
  
  1.1                  incubator-myfaces/src/components/org/apache/myfaces/custom/div/Div.java
  
  Index: Div.java
  ===================================================================
  /*
   * Copyright 2004 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.
   */
  package org.apache.myfaces.custom.div;
  
  import javax.faces.component.UIOutput;
  import javax.faces.context.FacesContext;
  import javax.faces.el.ValueBinding;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  /**
   * @author bdudney (latest modification by $Author: bdudney $) 
   * @version $Revision: 1.1 $ $Date: 2004/11/08 03:43:20 $ 
   * $Log: Div.java,v $
   * Revision 1.1  2004/11/08 03:43:20  bdudney
   * Added a div element. x:div to use, inserts a div with class or style attributes
   *
   */
  public class Div extends UIOutput {
    public static final String COMPONENT_TYPE = "org.apache.myfaces.Div";
    public static final String COMPONENT_FAMILY = "javax.faces.Output";
    private static final String DEFAULT_RENDERER_TYPE = DivRenderer.RENDERER_TYPE;
    private static final Log log = LogFactory.getLog(Div.class);
    private String _style = null;
    private String _styleClass = null;
  
    // ------------------------------------------------------------ Constructors
    public Div() {
      setRendererType(DEFAULT_RENDERER_TYPE);
    }
  
    public String getFamily() {
      return COMPONENT_FAMILY;
    }
  
    public String getStyle() {
      if (_style != null)
        return _style;
      ValueBinding vb = getValueBinding("style");
      return vb != null ? (String) vb.getValue(getFacesContext()) : null;
    }
  
    public void setStyle(String style) {
      this._style = style;
    }
  
    public String getStyleClass() {
      if (_styleClass != null)
        return _styleClass;
      ValueBinding vb = getValueBinding("styleClass");
      return vb != null ? (String) vb.getValue(getFacesContext()) : null;
    }
  
    public void setStyleClass(String styleClass) {
      this._styleClass = styleClass;
    }
  
    public void restoreState(FacesContext context, Object state) {
      Object values[] = (Object[]) state;
      super.restoreState(context, values[0]);
      _style = (String) values[1];
      _styleClass = (String) values[2];
    }
  
    public Object saveState(FacesContext context) {
      Object values[] = new Object[3];
      values[0] = super.saveState(context);
      values[1] = _style;
      values[2] = _styleClass;
      return values;
    }
  }
  
  
  1.1                  incubator-myfaces/src/components/org/apache/myfaces/custom/div/DivTag.java
  
  Index: DivTag.java
  ===================================================================
  /*
   * Copyright 2004 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.
   */
  package org.apache.myfaces.custom.div;
  
  import javax.faces.component.UIComponent;
  import org.apache.myfaces.taglib.html.HtmlOutputTextTagBase;
  /**
   * @author bdudney (latest modification by $Author: bdudney $) 
   * @version $Revision: 1.1 $ $Date: 2004/11/08 03:43:20 $ 
   * $Log: DivTag.java,v $
   * Revision 1.1  2004/11/08 03:43:20  bdudney
   * Added a div element. x:div to use, inserts a div with class or style attributes
   *
   */
  public class DivTag extends HtmlOutputTextTagBase {
    private String _style = null;
    private String _styleClass = null;
  
    public String getComponentType() {
      return Div.COMPONENT_TYPE;
    }
  
    public String getRendererType() {
      return DivRenderer.RENDERER_TYPE;
    }
  
    public void release() {
      super.release();
      this._style = null;
      this._styleClass = null;
    }
  
    /**
     * overrides setProperties() form UIComponentTag.
     */
    protected void setProperties(UIComponent component) {
      super.setProperties(component);
      setStringProperty(component, "style", _style);
      setStringProperty(component, "styleClass", _styleClass);
    }
  
    //---------------------------------------------only the Setters
    public void setStyle(String style) {
      this._style = style;
    }
  
    public void setStyleClass(String styleClass) {
      this._styleClass = styleClass;
    }
  }
  
  
  1.1                  incubator-myfaces/src/components/org/apache/myfaces/custom/div/DivRenderer.java
  
  Index: DivRenderer.java
  ===================================================================
  /*
   * Copyright 2004 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.
   */
  package org.apache.myfaces.custom.div;
  
  import java.io.IOException;
  import javax.faces.component.UIComponent;
  import javax.faces.context.FacesContext;
  import javax.faces.context.ResponseWriter;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.myfaces.renderkit.html.HTML;
  import org.apache.myfaces.renderkit.html.HtmlRenderer;
  /**
   * @author bdudney (latest modification by $Author: bdudney $) 
   * @version $Revision: 1.1 $ $Date: 2004/11/08 03:43:20 $ 
   * $Log: DivRenderer.java,v $
   * Revision 1.1  2004/11/08 03:43:20  bdudney
   * Added a div element. x:div to use, inserts a div with class or style attributes
   *
   */
  public class DivRenderer extends HtmlRenderer {
    private static final Log log = LogFactory.getLog(DivRenderer.class);
    public static final String RENDERER_TYPE = "org.apache.myfaces.DivRenderer";
  
    public void encodeBegin(FacesContext context, UIComponent component)
        throws IOException {
      if ((context == null) || (component == null)) {
        throw new NullPointerException();
      }
      Div div = (Div) component;
      ResponseWriter writer = context.getResponseWriter();
      writer.write("<" + HTML.DIV_ELEM +" ");
      String styleClass = div.getStyleClass();
      String style = div.getStyle();
      if(null == styleClass && null == style) {
        throw new IllegalStateException("Either style or styleClass must be specified");
      }
      if(null != styleClass && null != style) {
        throw new IllegalStateException("Only one of style or styleClass can be specified");
      }
      if(null != styleClass) {
        writer.write("class=" + styleClass);
      }
      if(null != style) {
        writer.write("style=" + style);
      }
      writer.write(">");
    }
  
    public void encodeEnd(FacesContext context, UIComponent component)
        throws IOException {
      if ((context == null) || (component == null)) {
        throw new NullPointerException();
      }
      ResponseWriter writer = context.getResponseWriter();
      writer.write("</" + HTML.DIV_ELEM + ">");
    }
  }
  
  
  1.34      +6 -3      incubator-myfaces/src/myfaces/org/apache/myfaces/el/VariableResolverImpl.java
  
  Index: VariableResolverImpl.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/myfaces/org/apache/myfaces/el/VariableResolverImpl.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- VariableResolverImpl.java	13 Oct 2004 11:51:00 -0000	1.33
  +++ VariableResolverImpl.java	8 Nov 2004 03:43:20 -0000	1.34
  @@ -36,6 +36,9 @@
    * @author Anton Koinov
    * @version $Revision$ $Date$
    * $Log$
  + * Revision 1.34  2004/11/08 03:43:20  bdudney
  + * Added a div element. x:div to use, inserts a div with class or style attributes
  + *
    * Revision 1.33  2004/10/13 11:51:00  matze
    * renamed packages to org.apache
    *
  @@ -342,7 +345,7 @@
               return obj;
           }
   
  -        log.error("Variable '" + name + "' could not be resolved.");
  +        log.warn("Variable '" + name + "' could not be resolved.");
           return null;
       }
   
  
  
  
  1.121     +26 -0     incubator-myfaces/tlds/myfaces_ext.tld
  
  Index: myfaces_ext.tld
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/tlds/myfaces_ext.tld,v
  retrieving revision 1.120
  retrieving revision 1.121
  diff -u -r1.120 -r1.121
  --- myfaces_ext.tld	29 Oct 2004 15:51:06 -0000	1.120
  +++ myfaces_ext.tld	8 Nov 2004 03:43:20 -0000	1.121
  @@ -1139,6 +1139,32 @@
   		</attribute>
   	</tag>
   
  +	<!-- div -->
  +	
  +	<tag>
  +		<name>div</name>
  +		<tag-class>org.apache.myfaces.custom.div.DivTag</tag-class>
  +		<body-content>JSP</body-content>
  +		<description>Places a div around its children</description>
  +		&ui_component_attributes;
  +		<attribute>
  +			<name>style</name>
  +			<required>false</required>
  +			<rtexprvalue>false</rtexprvalue>
  +			<description>
  +				The style to use for this div. Either style or styleClass must be specified but not
both.
  +			</description>
  +		</attribute>
  +		<attribute>
  +			<name>styleClass</name>
  +			<required>false</required>
  +			<rtexprvalue>false</rtexprvalue>
  +			<description>
  +				The class to use for this div. Either style or styleClass must be specified but not
both.
  +			</description>
  +		</attribute>
  +	</tag>
  +
   
       <!-- radio -->
       <tag>
  
  
  
  1.94      +11 -0     incubator-myfaces/conf/faces-config.xml
  
  Index: faces-config.xml
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/conf/faces-config.xml,v
  retrieving revision 1.93
  retrieving revision 1.94
  diff -u -r1.93 -r1.94
  --- faces-config.xml	13 Oct 2004 10:53:34 -0000	1.93
  +++ faces-config.xml	8 Nov 2004 03:43:20 -0000	1.94
  @@ -206,6 +206,11 @@
         <component-class>org.apache.myfaces.custom.stylesheet.Stylesheet</component-class>
     </component>
   
  +  <component>
  +        <component-type>org.apache.myfaces.Div</component-type>
  +      <component-class>org.apache.myfaces.custom.div.Div</component-class>
  +  </component>
  +
       <!-- additional "by type" converters -->
   
       <converter>
  @@ -402,6 +407,12 @@
             <component-family>javax.faces.Output</component-family>
             <renderer-type>org.apache.myfaces.Stylesheet</renderer-type>
             <renderer-class>org.apache.myfaces.custom.stylesheet.StylesheetRenderer</renderer-class>
  +      </renderer>
  +
  +      <renderer>
  +          <component-family>javax.faces.Output</component-family>
  +          <renderer-type>org.apache.myfaces.DivRenderer</renderer-type>
  +          <renderer-class>org.apache.myfaces.custom.div.DivRenderer</renderer-class>
         </renderer>
   
   
  
  
  

Mime
View raw message