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 8658105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:41:09+00:00 2026-06-12T15:41:09+00:00

I have a member variable in a managed bean, and this member variable is

  • 0

I have a member variable in a managed bean, and this member variable is tied to the component in XHTML with a getter and setter. If I set the member variable in a function call, when the getter of this member variable is trigger, this member variable will still hold the old value. May I know how could I update this member variable so that the component could get the latest updated value?

The manage bean:

@ManagedBean(name = "myBean")
@SessionScoped    
public class MyBean {
  public boolean show = false;

  /** getter and setter **/

  public void theFunc() {
     this.show = true;
  }
}

XHTML code

<h:panelGroup id="Panel_1" rendered="#{myBean.show == true}">
   ...
   Some rubbish here
   ...
</h:panelGroup>

<h:panelGroup id="Panel_2">
   <h:commandLink action="#{myBean.doFunc}">
      <f:ajax event="action" render="Panel_1"/>
      <h:outputText value="XX" />
   </h:commandLink>
</h:panelGroup>

From this sample, the show variable is showing false even though theFunc() has already set to true.

Update on 06 Oct 2012
I have remove commandButton and replace with commandLink, I think it should be fine in term of usage.

  • 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-12T15:41:10+00:00Added an answer on June 12, 2026 at 3:41 pm

    Change your methods return type and name if you want it to be invoked.

    Change this

      public void theFunc() {
         this.show = true;
      }
    

    to this

      public String doFunc() {
         this.show = true;
         return null;
      }
    

    otherwise this action can not work.

       <h:commandLink action="#{myBean.doFunc}">
    

    then update parent of your panel like this

    <h:panelGroup id="parentPanelGroupId">
    
        <h:panelGroup id="Panel_1" rendered="#{myBean.show}">
            ...
            Some rubbish here
            ...
        </h:panelGroup>
    
    </h:panelGroup>
    
    <h:panelGroup id="Panel_2">
       <h:commandLink action="#{myBean.doFunc}">
          <f:ajax render="parentPanelGroupId"/>
          <h:outputText value="SHOW/HIDE PANEL 1" />
       </h:commandLink>
    </h:panelGroup>
    

    NOTE:

    use

    rendered=”#{myBean.show}”

    instead of

    rendered=”#{myBean.show == true}”

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

Sidebar

Related Questions

The goal is to have the member variable _AddValue point to the CreateFirstValue function
I have seen member variables given a private modifier and then using getter/setter methods
If I have a member variable such as this (declared in the body of
I have a member variable that in a class that I want to make
I have a member variable which is a list of reference types. In a
I have a member variable that tells units for a value I have measured
I have a class that has a vector member variable, which I fill up
let's say I have std::map< std::string, std::string > m_someMap as a private member variable
I have a member variable in my Activity which is an ArrayList. The objects
I tried to have one static const member variable to relate to another static

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.