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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:06:46+00:00 2026-05-14T22:06:46+00:00

At my view I have two menus that I want to make dependent, namely,

  • 0

At my view I have two menus that I want to make dependent, namely, if first menu holds values “render second menu” and “don’t render second menu”, I want second menu to be rendered only if user selects “render second menu” option in the first menu. After second menu renders at the same page as the first one, user has to select current item from it, fill another fields and submit the form to store values in database. Both the lists of options are static, they are obtained from the database once and stay the same. My problem is I always get null as a value of the selected item from second menu. How to get a proper value? The sample code of view that holds problematic elements is:

<h:selectOneMenu id="renderSecond" value="#{Bean.renderSecondValue}"
                                 valueChangeListener="#{Bean.updateDependentMenus}"
                                 immediate="true"
                                 onchange="this.form.submit();" >
                    <f:selectItems value="#{Bean.typesOfRendering}" />
                </h:selectOneMenu><br />

<h:selectOneMenu id="iWillReturnYouZeroAnyway" value="#{Bean.currentItem}"
                                 rendered="#{Bean.rendered}" >
                    <f:selectItems value="#{Bean.items}" />
                </h:selectOneMenu><br />
<h:commandButton action="#{Bean.store}" value="#Store" />

However, if I remove “rendered” attribute from the second menu, everything works properly, except for displaying the menu for all the time that I try to prevent, so I suggest the problem is in behavior of dynamic rendering. The initial value of isRendered is false because the default item in first menu is “don’t render second menu”. When I change value in first menu and update isRendered with valueChangeListener, the second menu displays but it doesn’t initialize currentItem while submitting.

Some code from my backing bean is below:

public void updateDependentMenus(ValueChangeEvent value) {
    String newValue = (String) value.getNewValue();
        if ("render second menu" == newValue){
            isRendered = true;
        } else {
            isRendered = false;
        }
}

public String store(){
    System.out.println(currentItem);
    return "stored";
}
  • 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-05-14T22:06:47+00:00Added an answer on May 14, 2026 at 10:06 pm

    If you’re using the rendered attribute on UIInput and UICommand components, then you have to make sure that the rendered condition evaluates exactly the same way in the subsequent request (during submitting the form) as it was during the initial request (during displaying the form). When it evaluates false, then the request values won’t be applied/validated and the model values won’t be updated and no action will be invoked for the component(s) in question.

    An easy fix is to put the bean in the session scope, but this has caveats as well (poor user experience when opening same page in multiple browser tabs/windows). On JSF 2.0 you could use the view scope instead. On JSF 1.x you would use Tomahawk’s t:saveState for this.

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

Sidebar

Related Questions

I have two view controllers that allow changes to the Address Book. The first
I have application where i have two view controllers my first view and second
I have two dropdown hidden menus ie menu A and menu B that shows
I have two view controllers. My first is my menu which contains my highscore
I have two partial view and I want to call one of them in
I have a page that i want to remain static with two divs that
suppose I have a model and a view ,ths view have two method:one is
I have two view controller classes in my application delegate. I can change from
I have two view controllers in a tabbar which can both edit data. Therefore,
I have two view controllers name RootViewController and SecondViewController. In the FirstViewController I have

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.