View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.renderkit.html.ext;
20  
21  import java.io.IOException;
22  import javax.faces.context.FacesContext;
23  import javax.faces.context.ResponseWriter;
24  import javax.faces.component.UIComponent;
25  import org.apache.myfaces.component.html.ext.HtmlPanelGroup;
26  import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
27  import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlGridRendererBase;
28  
29  /**
30   * X-CHECKED: tlddoc h:panelGrid 1.0 final
31   *
32   * @JSFRenderer
33   *   renderKitId = "HTML_BASIC"
34   *   family = "javax.faces.Panel"
35   *   type = "org.apache.myfaces.Grid"
36   *
37   * @author Martin Marinschek (latest modification by $Author: grantsmith $)
38   * @version $Revision: 169655 $ $Date: 2005-05-11 18:45:06 +0200 (Wed, 11 May 2005) $
39   */
40  public class HtmlGridRenderer
41      extends HtmlGridRendererBase
42  {
43      protected int childAttributes(FacesContext context,
44              ResponseWriter writer,
45              UIComponent component,
46              int columnIndex)
47          throws IOException
48      {
49          if (component instanceof HtmlPanelGroup && ((HtmlPanelGroup)component).getColspan() != HtmlPanelGroup.DEFAULT_COLSPAN) {
50              int colspan = ((HtmlPanelGroup)component).getColspan();
51              writer.writeAttribute(HTML.COLSPAN_ATTR, "" + colspan, null);
52              columnIndex += (colspan - 1);
53          }
54          return columnIndex;
55      }
56  }