EncodeBegin vs encodeEnd in JSF and which should be preferable

I am using the javax.faces.render.Renderer class to display my custom components. To achieve the desired result, I override either encodeBegin or encodeEnd .

I would like to know when to use any of these methods? Is there any directive about when to use encodeBegin and encodeEnd ?

+4
source share
1 answer

It depends on the hierarchy of the component tree. Key, are you expecting children? How do you want the encoded output to look when there are children?

Usually you use encodeBegin() if you want to encode the output before the children are encoded. For instance. start tag such as HTML <div> . Usually you use encodeEnd() if you want to encode the output after the children are encoded. For instance. end tag such as HTML </div> . Or perhaps an additional <script> that should work with the previously created <div> .

+5
source

Source: https://habr.com/ru/post/1490704/


All Articles