views:

19

answers:

2

Is there any way to change left-margins for the nodes? Tree2 renders those margins with columns such as:

<td height="100%" width="19" style=""><img height="18" border="0" width="19" src="/vwwinner/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/12806587/tree2.HtmlTreeRenderer/images/spacer.gif" alt="spacer"></td>

19 px width is too big for me, so I'd be glad to find out how to change this value.

A: 

You can always override the width value with css.

td { width: 100px; }

It should be possible to specify styleClass for the treeNode.

In any case the width attribute on the td element is deprecated and css should be used instead.

mmanco
A: 

Well, for unknown reasons that value was hardcoded in t:tree2 renderer class (HtmlTreeRenderer):

protected void encodeCurrentNode(...) {
        .....
        out.writeAttribute(HTML.WIDTH_ATTR, "19", null);
        out.writeAttribute(HTML.HEIGHT_ATTR, "100%", null);
        ...
}

So I just extended that class, overrided encodeCurrentNode() method and registered my renderer in faces-config.xml:

<render-kit>
  <render-kit-id>HTML_BASIC</render-kit-id>
  <renderer>
      <component-family>org.apache.myfaces.HtmlTree2 </component-family>
    <renderer-type>
        org.apache.myfaces.HtmlTree2 
    </renderer-type>
    <renderer-class>
        com.myapp.MyHtmlTreeRenderer
    </renderer-class>
 </renderer>
</render-kit>
n0weak