encodeBegin vs encodeEnd in JSF and which one should be preferred
jsf, jsf-1.2
Solution
That depends on the component tree hierarchy. Key is, do you expect children? How do you want the encoded output to look like when there are children?
Usually, you use `encodeBegin()` if you want to encode output before children are encoded. E.g. a start tag like HTML `<div>`. Usually, you use `encodeEnd()` if you want to encode output after children are encoded. E.g. an end tag like HTML `</div>`. Or perhaps an additional `<script>` which should work on the before-generated `<div>`.
Problem
I am using the `javax.faces.render.Renderer` class to render my custom components. I override either `encodeBegin` or `encodeEnd` to achieve my desired output. I would like to know when should I use either of these methods? Is there any guideline on when should `encodeBegin` and `encodeEnd` be used?