The changes made in trunk of 1.2.6 plugins are necessary to make this
solution work.

I think that the spec is wrong, the component type of HtmlColumnTag
should be javax.faces.HtmlColumn and not
javax.faces.Column. But we need to be according to the spec if we want
a release, so is a fact that the component
type for this tag class is javax.faces.Column.

I have made a full revision of the solution applied that comply with
the spec including the changes on plugins.

Looking the latest log on maven-faces-plugin, I have noted the changes:

org.apache.myfaces.trinidadbuild.plugin.faces.generator.taglib.MyFacesComponentTagGenerator


  public void writeGetComponentType(PrettyWriter out,
                                    ComponentBean component) throws IOException
  {
    String componentType = component.getComponentType();
    if("javax.faces.HtmlColumn".equals(componentType))
    {
      componentType = "javax.faces.Column";
    }

   .....

This is what the spec says


  protected void writeSetPropertyMethodBody(PrettyWriter out,
                                            String componentClass,
                                            Iterator properties)
throws IOException
  {

    if("HtmlColumn".equals(componentClass))
    {
        componentClass = "UIColumn";
    }

    .......

This is fine, because as side effect of set the component type now we
are creating UIColumn instances and
not HtmlColumn instances (note that HtmlColumn will not be used anymore!!! ).

The effect of this changes is generate a proper tag class.
(org.apache.myfaces.taglib.html.HtmlColumnTag)

Now the side effects of this change. The class that render columns on myfaces is

org.apache.myfaces.shared.renderkit.html.HtmlTableRendererBase

so the change that we need is this:

   protected void renderColumnChildHeaderOrFooterRow(FacesContext facesContext,
       ResponseWriter writer, UIComponent uiComponent, String
styleClass, boolean isHeader) throws IOException
   {
       if (uiComponent instanceof UIColumn)
       {
           // allow column to override style class, new in JSF 1.2
           if (uiComponent instanceof HtmlColumn) {
               HtmlColumn column = (HtmlColumn)uiComponent;
               if (isHeader && column.getHeaderClass()!=null)
                   styleClass = column.getHeaderClass();
               else if (!isHeader && column.getFooterClass()!=null)
                   styleClass = column.getFooterClass();
           }else{
               //This code corrects MYFACES-1790, because HtmlColumnTag
               //has as component type javax.faces.Column, so as side
               //effect it not create HtmlColumn, it create UIColumn
               //classes.
               UIColumn column = (UIColumn) uiComponent;
               if (isHeader){
                   String headerClass = (String)
column.getAttributes().get("headerClass");
                   if (headerClass != null){
                       styleClass = (String) headerClass;
                   }
               }else{
                   String footerClass = (String)
column.getAttributes().get("footerClass");
                   if (footerClass != null){
                       styleClass = (String) footerClass;
                   }
               }
           }

          ......................

Tested with myfaces only and myfaces+facelets works as jsf ri.

Reply via email to