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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:24:59+00:00 2026-06-10T01:24:59+00:00

I have two dropdowns in one form. The first contains those options: String[] decisions

  • 0

I have two dropdowns in one form. The first contains those options:

String[] decisions = {"acceptée", "rejettée"};

When “rejettée” is selected, I would like to disable the second dropdown.

Here is the relevant code of the two dropdowns:

<p:selectOneMenu required="true" requiredMessage="veuillez choisir une decision" id="dec" value="#{editCommandController.myCom.decision}">  
    <f:selectItems value="#{editCommandController.decisions}" />            
</p:selectOneMenu>  
<p:selectOneMenu  id="etat" value="#{editCommandController.myCom.etat}">  
    <f:selectItems value="#{editCommandController.etats}" />   
</p:selectOneMenu>  

How can I achieve this?

  • 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-10T01:25:01+00:00Added an answer on June 10, 2026 at 1:25 am

    Try this:

    <h:outputLabel for="dec" value="Decision : " />
        <p:selectOneMenu required="true"
            requiredMessage="veuillez choisir une decision" id="dec"
            value="#{editCommandController.myCom.decision}">
            <f:selectItems value="#{editCommandController.decisions}" />
            <p:ajax update="etat" event="change"/>
        </p:selectOneMenu>
        <p:message for="dec" display="icon" />
    
        <h:outputLabel for="etat" value="Etat : " />
        <p:selectOneMenu id="etat" value="#{editCommandController.myCom.etat}" disabled="#{editCommandController.myCom.decision eq 'rejettée'}">
            <f:selectItems value="#{editCommandController.etats}" />
        </p:selectOneMenu>
        <p:message for="etat" display="icon" />
    

    To set to some default value on change, try this:

    <h:outputLabel for="dec" value="Decision : " />
    <p:selectOneMenu required="true"
        requiredMessage="veuillez choisir une decision" id="dec"
        value="#{editCommandController.myCom.decision}" valueChangeListener="#{editCommandController.vclistener}">
        <f:selectItems value="#{editCommandController.decisions}" />
        <p:ajax />
    </p:selectOneMenu>
    <p:message for="dec" display="icon" />
    
    <h:outputLabel for="etat" value="Etat : " />
    <p:selectOneMenu id="etat" value="#{editCommandController.myCom.etat}" disabled="#{editCommandController.myCom.decision ne 'rejettée'}">
        <f:selectItems value="#{editCommandController.etats}" />
    </p:selectOneMenu>
    <p:message for="etat" display="icon" />
    

    And then in the backing bean add the selectItem if not already present otherwise you can skip it:

    public static List<SelectItem> etats = new ArrayList<SelectItem>() { {
        add(new SelectItem("Cheese", "Cheese"));
        add(new SelectItem("Pickle", "Pickle"));
        add(new SelectItem("Mustard", "Mustard"));
        add(new SelectItem("Lettuce", "Lettuce"));
    }};
    
    public void vclistener(ValueChangeEvent e){
        if(e.getNewValue().equals("rejettée")){
            EditCommandController.etats.add(0, new SelectItem("Ketchup", "Ketchup"));
            myCom.setEtat("Ketchup");
        }
        RequestContext.getCurrentInstance().update("etat");
    }
    
    public List<SelectItem> getEtats() {
        return etats;
    }
    
    public void setEtats(List<SelectItem> etats) {
        EditCommandController.etats = etats;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two dropdowns in my form. The first one Queries for a set
I have a form on my page which contains two select dropdowns. The first
I am using Asp.net dropdownlist in one of my form ..I have two dropdown
I have two cascading dropdowns and one gridview control. on page load iam binding
I have two dropdowns in extjs,based on the first dropdwon,the second dropdown populates.This is
i have two dropdown list. first drop down:1 enter code here <form:select path=custName id=custName>
I have the form with selected boxes like below. i need to group the
I have two dropdown boxes in one form - only one option can be
Am I doing this correctly? I have two dropdowns. The first is populated on
In a form I have one Date text field and 2 dropdowns: Start time

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.