Just extended my first jsf component. but in the right way?

Hi all,
After days of trial and error, i finally managed to code my own JSF component, extending existing infrastructure. Since things just suddenly fell in place during a brute force approach to make it work, i'd like to ask for opinions of seasoned JSF veterans whether this makes sense or there is a better way to do things.
The objective was to be able to render a collection of items as a comma separated list. To this end, I took an existing data iterator UIComponent from richfaces, added a custom renderer -- again extending on richfaces, and hooked things up in 2 config files, as follows:
CsvRenderer.java:
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.component.UIDataAdaptor;
import org.richfaces.renderkit.AbstractRowsRenderer;
import org.richfaces.renderkit.TableHolder;
/** Renders a richfaces UIDataList component as a comma separated list */
public class CsvRenderer extends AbstractRowsRenderer {
     @Override
     public void encodeOneRow(FacesContext context, TableHolder holder)     throws IOException {
          UIDataAdaptor table = holder.getTable();
          ResponseWriter writer = context.getResponseWriter();
          renderChildren(context, table);
          if(holder.getRowCounter() < table.getRowCount() - 1) {
               writer.write(", ");
     @Override
     protected Class<? extends UIComponent> getComponentClass() {
          return org.richfaces.component.UIDataList.class;
added to faces-config.xml:
<render-kit>
     <render-kit-id>HTML_BASIC</render-kit-id>
     <renderer>
          <component-family>org.richfaces.DataList</component-family>
          <renderer-type>ahui.CsvRenderer</renderer-type>
          <renderer-class>com.b2international.auctionhouse.jsf.ahui.CsvRenderer</renderer-class>
     </renderer>
</render-kit>
added to ahui.taglib.xml:
<tag>
     <tag-name>csv</tag-name>
     <component>
          <component-type>org.richfaces.DataList</component-type>
          <renderer-type>ahui.CsvRenderer</renderer-type>
     </component>
</tag>
cheers,
Greg

Hi all,
After days of trial and error, i finally managed to code my own JSF component, extending existing infrastructure. Since things just suddenly fell in place during a brute force approach to make it work, i'd like to ask for opinions of seasoned JSF veterans whether this makes sense or there is a better way to do things.
The objective was to be able to render a collection of items as a comma separated list. To this end, I took an existing data iterator UIComponent from richfaces, added a custom renderer -- again extending on richfaces, and hooked things up in 2 config files, as follows:
CsvRenderer.java:
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.component.UIDataAdaptor;
import org.richfaces.renderkit.AbstractRowsRenderer;
import org.richfaces.renderkit.TableHolder;
/** Renders a richfaces UIDataList component as a comma separated list */
public class CsvRenderer extends AbstractRowsRenderer {
     @Override
     public void encodeOneRow(FacesContext context, TableHolder holder)     throws IOException {
          UIDataAdaptor table = holder.getTable();
          ResponseWriter writer = context.getResponseWriter();
          renderChildren(context, table);
          if(holder.getRowCounter() < table.getRowCount() - 1) {
               writer.write(", ");
     @Override
     protected Class<? extends UIComponent> getComponentClass() {
          return org.richfaces.component.UIDataList.class;
added to faces-config.xml:
<render-kit>
     <render-kit-id>HTML_BASIC</render-kit-id>
     <renderer>
          <component-family>org.richfaces.DataList</component-family>
          <renderer-type>ahui.CsvRenderer</renderer-type>
          <renderer-class>com.b2international.auctionhouse.jsf.ahui.CsvRenderer</renderer-class>
     </renderer>
</render-kit>
added to ahui.taglib.xml:
<tag>
     <tag-name>csv</tag-name>
     <component>
          <component-type>org.richfaces.DataList</component-type>
          <renderer-type>ahui.CsvRenderer</renderer-type>
     </component>
</tag>
cheers,
Greg

Similar Messages

Maybe you are looking for