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

  • SEARCH
  • Home
  • 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 7997853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:04:02+00:00 2026-06-04T15:04:02+00:00

I am creating a simple page that will, after clicking a button, replace one

  • 0

I am creating a simple page that will, after clicking a button, replace one panelGroup with another. First, the code:

<h:body>

    <ui:composition template="/elements/templateWithMenu.xhtml">           
        <ui:define name="content">
            <div class="rightContent">

                <h:panelGroup id="lol" rendered="#{test.firstStep.booleanValue()}">

                    <h3>This should disappear</h3>

                    <h:form id="newPollForm1" rendered="#{test.firstStep.booleanValue()}"> 
                        <fieldset>
                            <h:commandLink value="Next" action="#{test.firstStepCompleted()}" >
                                <f:ajax execute="@all" render="lol" />
                            </h:commandLink>
                        </fieldset>
                    </h:form>

                </h:panelGroup>

                <h:panelGroup rendered="#{test.secondStep.booleanValue()}">
                    Works!
                </h:panelGroup>

            </div>     
        </ui:define>
    </ui:composition>

</h:body>

The backing bean simply sets the firstStep as false, and secondStep as true.

Now, when I tried running this, I got <f:ajax> contains an unknown id 'lol' - cannot locate it in the context of the component j_idt39. After googling a bit, I found out that for elements outside the form’s scope, I need to use SEPARATOR_CHAR (:). That didn’t work. So I tried messing with different combinations of #{component} and #{cc}, but nothing works. I even found this awesome explanation, but again, I failed miserably. If I use @all, everything goes ok (one panel is replaced with another), but I really need to render a specific component.

Help? Please?

  • 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-04T15:04:03+00:00Added an answer on June 4, 2026 at 3:04 pm

    You need to update the common parent <div class="rightContent"> instead. This one is always rendered and thus guarantees that JavaScript/Ajax can access and mainpulate its children. Replace it by <h:panelGroup layout="block"> and give it an id.

    <h:panelGroup layout="block" id="content" class="rightContent">
        <h:panelGroup rendered="#{test.firstStep}">
            <h3>This should disappear</h3>
            <h:form id="newPollForm1"> 
                <fieldset>
                    <h:commandLink value="Next" action="#{test.firstStepCompleted()}" >
                        <f:ajax execute="@form" render=":content" />
                    </h:commandLink>
                </fieldset>
            </h:form>
        </h:panelGroup>
    
        <h:panelGroup rendered="#{test.secondStep}">
            Works!
        </h:panelGroup>
    </h:panelGroup>
    

    Using this Test.java class:

    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.ViewScoped;
    
    @ManagedBean
    @ViewScoped
    public class Test {
        private int number = 0;
    
        public void firstStepCompleted() {
            number++;
        }
    
        public boolean isFirstStep() {
            return number == 0;
        }
    
        public boolean isSecondStep() {
            return number == 1;
        }
    }
    

    Note that I removed the superfluous Boolean#booleanValue() calls and the duplicated rendered contition on the form.

    If that still doesn’t work, then the /elements/templateWithMenu.xhtml apparently contains another naming container component which has prepended its ID. For starters who haven’t memorized all naming container components yet, an easy way to figure the real right client ID is to open the page in browser, rightclick and View Source and then locate the JSF-generated HTML element and take exactly its id attribute value (and prefix it with : in the <f:ajax render>).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating a simple RPG game, first time using XNA. Trying to get my character
I am creating a simple application with Django. I realized that I am doing
I was wondering what will happen if I make 2 ajax calls one after
I'm creating a simple page with a form. Part of the form requires uploading
in my module i am creating a page with many simple forms: foreach ($parameters
Greetings! I'm creating a web form prototype (ImageLaoder.aspx) that will return an image so
I am creating a logging object that will take all logs sent to it
I am creating a widget that will be installed across different sites. The widget
I'm creating simple payment form that allows users to select from several different gateways
I'm creating a webapp where upon connecting to my server, you will have one

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.