In order to improve the ability to customize the rendering of Trinidad
components, an idea was proposed in the "private / protected final
methods in renderers" thread.

This idea is to replace existing code that has hard references to sub
renderers (directly instantiating Trinidad renderers from within other
renderers) with a lookup into the faces context.

So for example, in TableRenderer, a _detailRenderer is used to render
the detail column. That variable is instantiated as:
private final SpecialColumnRenderer _detailRenderer = new
DetailColumnRenderer();

If this _detailRenderer was built using a lookup into the renderkit
for a certain renderer type, then users could extend or replace the
manner in which the table renders the detail column.

I have prototyped this code in this branch:
http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_subRendererPerfTesting

To see this as a patch/diff you can use this command:
svn diff -r647358:HEAD
https://svn.apache.org/repos/asf/myfaces/trinidad/branches/ar_subRendererPerfTesting

The problem with this prototype is that it does not incorporate how
sub-classed sub-renderers are sometimes used within the code. For
example, the LabelAndMessageRenderer contains an inner class Label
that extends OutputLabelRenderer. Here is a function from that class:
    protected String getDefaultValign(FacesBean bean)
    {
      // get the defaultLabelValign from the form component.
      return getDefaultLabelValign(bean);
    }

As you can see, it uses inheritance to get the valign from the label
valign property.

So there are multiple ways to probably code this without inheritance.
One is to let the renderer wrap the FacesBean to "alias" properties.
In this case, from the valign to the label's valign. But is that
enough?

Please discuss this last point and for those that are more familiar
with the renderers that use subclassing of renderers please mention
use cases that this may not work and maybe ways that a different
solution could.

Thank you,
Andrew

Reply via email to