Permalink
Browse files

TableHeaderCell and Alternative TableRenderer

  • Loading branch information...
camac committed Nov 26, 2017
1 parent 77d9f9d commit 145e5ccffd4d49e184c5c9b7295560769dec29c6
@@ -9,4 +9,6 @@ Require-Bundle: com.ibm.commons,
com.ibm.xsp.extsn, com.ibm.xsp.extsn,
com.ibm.xsp.extlib, com.ibm.xsp.extlib,
com.ibm.xsp.extlibx.core com.ibm.xsp.extlibx.core
Export-Package: com.ibm.xsp.extlibx.controls.config Export-Package: com.ibm.xsp.extlibx.component.table,
com.ibm.xsp.extlibx.controls.config,
com.ibm.xsp.extlibx.renderkit.table
@@ -0,0 +1,14 @@
package com.ibm.xsp.extlibx.component.table;
import com.ibm.xsp.component.xp.XspTableCell;
public class UITableHeaderCell extends XspTableCell {
public static final String RENDERER_TYPE = "com.ibm.xsp.extlibx.TableHeaderCell";
public UITableHeaderCell() {
super();
setRendererType(RENDERER_TYPE);
}
}
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
<render-kit>
<renderer>
<component-family>com.ibm.xsp.Tag</component-family>
<renderer-type>com.ibm.xsp.extlibx.TableHeaderCell</renderer-type>
<renderer-class>com.ibm.xsp.extlibx.renderkit.table.HtmlTableHeaderCellRenderer</renderer-class>
</renderer>
<renderer>
<component-family>com.ibm.xsp.Tag</component-family>
<renderer-type>com.ibm.xsp.extlibx.Table</renderer-type>
<renderer-class>com.ibm.xsp.extlibx.renderkit.table.HtmlTableRenderer</renderer-class>
</renderer>
</render-kit>
</faces-config>
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
<faces-config-extension>
<namespace-uri>http://www.ibm.com/xsp/coreex</namespace-uri>
<default-prefix>xe</default-prefix>
</faces-config-extension>
<!-- Table Header Cell -->
<component>
<description>A control that displays a single cell in a table row.</description>
<display-name>Table Header Cell</display-name>
<component-type>com.ibm.xsp.TableHeaderCell</component-type>
<component-class>com.ibm.xsp.extlibx.component.table.UITableHeaderCell</component-class>
<component-extension>
<javadoc-description>XPages Container Controls - Table Header Cell</javadoc-description>
<base-component-type>com.ibm.xsp.TableCell</base-component-type>
<component-family>com.ibm.xsp.Tag</component-family>
<renderer-type>com.ibm.xsp.extlibx.TableHeaderCell</renderer-type>
<tag-name>th</tag-name>
<designer-extension>
<generate-id>false</generate-id>
</designer-extension>
</component-extension>
</component>
</faces-config>
@@ -0,0 +1,25 @@
package com.ibm.xsp.extlibx.renderkit.table;
import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import com.ibm.xsp.renderkit.html_extended.HtmlTableCellRenderer;
public class HtmlTableHeaderCellRenderer extends HtmlTableCellRenderer {
public static final String TAG = "th";
public static final String[] ATTRS = { "rowspan", "colspan", "align", "valign", "title", "role" };
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
super.encodeBegin(context, component, TAG, ATTRS);
}
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
super.encodeEnd(context, component, TAG);
}
}
@@ -0,0 +1,48 @@
package com.ibm.xsp.extlibx.renderkit.table;
import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import com.ibm.xsp.util.FacesUtil;
public class HtmlTableRenderer extends com.ibm.xsp.renderkit.html_extended.HtmlTableRenderer {
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
super.encodeBegin(context, component);
ResponseWriter w = context.getResponseWriter();
UIComponent thead = component.getFacet("thead");
if (thead != null) {
w.startElement("thead", null);
FacesUtil.renderComponent(context, thead);
w.endElement("thead");
}
UIComponent tfoot = component.getFacet("tfoot");
if (tfoot != null) {
w.startElement("tfoot", null);
FacesUtil.renderComponent(context, tfoot);
w.endElement("tfoot");
}
w.startElement("tbody", null);
}
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
context.getResponseWriter().endElement("tbody");
super.encodeEnd(context, component);
}
}

0 comments on commit 145e5cc

Please sign in to comment.