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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:33:06+00:00 2026-05-31T20:33:06+00:00

I have two drop downs on a page whose backing bean is Request Scoped.

  • 0

I have two drop downs on a page whose backing bean is Request Scoped. The second drop down is always disabled when the page is first rendered. However, if the user switches the first drop down to a different value than the default, the second drop down is enabled. When the user submits the form, I want my RequestScoped managed bean to see the value of the second drop down. However, evidently, becuase the second drop down was initially disabled, its value is not submitted with the form, even though when the form was submitted, the dropdown was enabled.

The way I have worked around this is to store the disabled “state” of the second drop down in a ViewScoped bean. That way, when the user changes the first drop down to a value other than the default, an actionListener can fire which will update the value of the ViewScoped bean associated with the second dropdown (changing its state to not disabled).

Is this the best way to deal with this situation? Or is there a better way?

  • 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-31T20:33:08+00:00Added an answer on May 31, 2026 at 8:33 pm

    That’s indeed the most sane approach.

    An alternative, if you really need to have your bean in the request scope, is to re-determine the disabled state of the second dropdown in the (post)constructor of the bean based on the submitted value of the first dropdown which you can find in the request parameter map (or just let JSF set it by @ManagedProperty). You only need to manually repeat the JSF conversion/validation if necessary.

    Let’s assume that the second dropdown should not be disabled anymore when the submitted value of the first dropdown equals the string value foo and that the client ID of the first dropdown is form:dropdown1:

    public Bean() {
        this.dropdown2disabled = !"foo".equals(FacesContext.getCurrentInstance()
            .getExternalContext().getRequestParameterMap().get("form:dropdown1"));
    }
    

    But as you found out, a view scoped bean is easier.

    As again another alternative, you could use Tomahawk’s <t:saveState> to store a single property directly in the view state. Add this somewhere to the view then:

    <t:saveState value="#{bean.dropdown2disabled}" />
    

    This will result in a smaller size of the view state than when using a view scoped bean.

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

Sidebar

Related Questions

In my application i have two drop down boxes first box had origin second
I have two drop down list on a page. The first one list projects
I have a user control in a master page with two drop down lists.
Simple ASP.NET application. I have two drop-down controls. On the first-drop down I have
i have two dropdown list. first drop down:1 enter code here <form:select path=custName id=custName>
I have two Drop Down Lists, the second ones are based off which one
I have a simple page with two drop downs, one for country and one
I have two drop down lists. Second one is populated based on value chosen
I have two drop down lists on a page. The behavior is as follows:
I have JSF page has two drop down lists and I want to load

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.