Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8344079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:15:20+00:00 2026-06-09T06:15:20+00:00

Is it possible to add a child component during render? If not what would

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:15:21+00:00Added an answer on June 9, 2026 at 6:15 am

    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:

    public class ViewModifierPhaseListener implements
            javax.faces.event.PhaseListener {
    
        @Override
        public void afterPhase(PhaseEvent event) {
        }
    
        // Just sampling add component on ViewRoot
        @Override
        public void beforePhase(PhaseEvent event) {
            // Gets the target component from ViewRoot
            UIViewRoot viewRoot = event.getFacesContext().getViewRoot();
            UIComponent parent = viewRoot.findComponent("parentComponentId");
            // UIComponents to create depend on JSF implementation, 
            // Try to use the available factories when suplied by the implementation
            UIComponent child = Factory.getComponent("ComponentClassName");
            // Customize the component, for instance it has to be disabled
            child.getAttributes().put("disabled", true);
            // Adds the fresh created component to the parent
            parent.getChildren().add(child);
        }
    
        @Override
        public PhaseId getPhaseId() {
            return PhaseId.RENDER_RESPONSE;
        }
    }
    

    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:

    <lifecycle>
        <phase-listener>your.package.ViewModifierPhaseListener</phase-listener>
    </lifecycle>
    

    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.

    <f:phaseListener type="your.package.ViewModifierPhaseListener"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to reuse a parent method in a child method and add
Is it possible to add sprite feature in XTK ? I need to render
is it possible to add an instance of a java application as a child
Is it possible to place a child component inside a JButton and make it
Possible Duplicate: How is possible add child to the specific node how i can
Is it possible to add something with innerHTML before/after the nth child of <body>
Is it possible to add a child to the current frame only? I know
Is it possible to add views to a layout during the onLayout event of
Is it possible to add or remove slides in runtime using FlexSlider ?
Is it possible to add button click event by clicking design of axml? if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.