Is it possible to add a child component during render? If not what would be the best practice to add a child component dynamically in a JSF 1.2 Environment? Thanks
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The better place where you can do that is in a PhaseListener implementation.
For instance the next code snippet samples how you can add a new component in to the view root:
Please note that getPhaseId returns the RENDER_RESPONSE phase because in that phase is where you have the components tree complete.
Your phase listener definition has to be set in the faces-config.xml’s lifecycle element like this:
Or if you work with facelets you could define it in the template of the pages you want to be affected by your listener. This helps you to discriminate when to execute your PhaseListener.