Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the relationship between component family, component type and renderer type?
    text
    copied!<p>When I am learning custom component development in JSF, I got confused with the relationship between component family, component type and renderer type. For example, I registered a renderer and a custom component as shown below.</p> <p><code>faces-config.xml</code>:</p> <pre class="lang-xml prettyprint-override"><code>&lt;component&gt; &lt;component-type&gt;study.faces.Div&lt;/component-type&gt; &lt;component-class&gt;javax.faces.component.UIPanel&lt;/component-class&gt; &lt;/component&gt; &lt;render-kit&gt; &lt;render-kit-id&gt;HTML_BASIC&lt;/render-kit-id&gt; &lt;renderer&gt; &lt;component-family&gt;javax.faces.Panel&lt;/component-family&gt; &lt;renderer-type&gt;study.faces.DivRenderer&lt;/renderer-type&gt; &lt;renderer-class&gt;com.study.ui.DivRenderer&lt;/renderer-class&gt; &lt;/renderer&gt; &lt;/render-kit&gt; </code></pre> <p>I also registered a new tag in <code>my.taglib.xml</code> file as below:</p> <pre class="lang-xml prettyprint-override"><code>&lt;tag&gt; &lt;tag-name&gt;div&lt;/tag-name&gt; &lt;component&gt; &lt;component-type&gt;study.faces.Div&lt;/component-type&gt; &lt;renderer-type&gt;study.faces.DivRenderer&lt;/renderer-type&gt; &lt;/component&gt; &lt;/tag&gt; </code></pre> <p>This configuration works very well. However, I didn't understand why the line <code>&lt;component-family&gt;javax.faces.Panel&lt;/component-family&gt;</code> is required on renderer registration. In <code>my.taglib.xml</code>, the component and the renderer is connected and, IMHO, it should have been enough to select an appropriate renderer for the component. What is the use of the additional parameter <code>&lt;component-family&gt;</code>?</p> <p>I did Google researches and all the answers I got say like "One renderer can be used to render multiple components. These components belong to one family". But these statements didn't clear my confusion up. Can someone explain the relationship between component type, component family and renderer selection strategy? (Hopefully with a good example.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload