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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:03:19+00:00 2026-06-17T22:03:19+00:00

In my application I have three dropdown menu ( p:selectOneMenu ), say A, B,

  • 0

In my application I have three dropdown menu (p:selectOneMenu), say A, B, C. Among them two are dependent, say B and C. By changing the value of B I am dynamically loading values to C. Also there is a textbox. The value of the textbox is generating by ajax when the on-change event is firing from these three dropdowns.

Here is the xhtml:

<p:selectOneMenu id="customerMenu" value="#{adminController.activityDTO.customerId}" required="true" label="Customer Name" style="width: 200px">
    <f:selectItem itemLabel="Select One" itemValue="" />
    <f:selectItems value="#{adminController.customers}" var="customer" itemLabel="#{customer.customerName}" itemValue="#{customer.customerId}" />
    <p:ajax listener="#{adminController.generateActivityName}" update="activityId" />                       
</p:selectOneMenu>

<p:selectOneMenu id="activityTypeMenu" value="#{adminController.activityDTO.activityParentType}" required="true" label="Activity Type"
    style="width: 200px">
    <f:selectItem itemLabel="Select One" itemValue="" />
    <f:selectItems value="#{adminController.activityTypes}" var="activityType" itemLabel="#{activityType.parent}" itemValue="#{activityType.parent}" />
    <p:ajax listener="#{adminController.updateDependentActivity}" update="activitySubType" />
</p:selectOneMenu>

<p:selectOneMenu id="activitySubTypeMenu" value="#{adminController.activityDTO.activitySubType}" required="true" label="Activity Sub Type"
    style="width: 200px">
    <f:selectItem itemLabel="Select One" itemValue="" />
    <f:selectItems value="#{adminController.activitySubTypes}" var="activityType" itemLabel="#{activityType.name}" itemValue="#{activityType.id}" />
    <p:ajax listener="#{adminController.generateActivityId}" update="activityId" />
</p:selectOneMenu>

<p:inputText id="activityId" autocomplete="off" readonly="true" value="#{adminController.activityDTO.activityId}"
    label="#{adbBundle['admin.addActivityPanel.addActivityTable.activityId']}" required="true" />

The activityTypeMenu and activitySubTypeMenu are dependent, by the selected value of the activityTypeMenu I am populating the activitySubTypeMenu.

Now the problems that I am facing is:

  • Say I have select “External” and “Internal” in activityTypeMenu and default “Select One”. If I choose “External” from activityTypeMenu the activitySubTypeMenu will have “Project” and “Service”. But then if I choose the default “Select One” the activitySubTypeMenu is still holding the previously dynamically populated values. This is because the required="true" attribute resisting to fire the backend method from which I am loading the dynamic value.
  • I have tried to set the itemValue of <f:selectItem itemLabel="Select One" itemValue="" /> to #{null} and then the backend method is firing on selecting the “Select one” option and I can set an empty list to activitySubTypes and this way the activitySubTypeMenu get empty. But in that case the required="true" is getting meaningless. I mean, I also have save button and on clicking that button without selecting any option (that is selecting “Select one”) from activityTypeMenu and activitySubTypeMenu not throwing ValidatorException and the components are not getting styled by the error css class of Primefaces.
  • Also if I don’t set the itemValue of <f:selectItem itemLabel="Select One" itemValue="" /> to #{null} then on-changing to selected value to default option(“Select one”) does not clearing out the activityId p:inputText. If I use #{null} then I can get the backend method firing from which I can set the value of the textbox to empty.

How ca i solve this issues and get desired result. What I want are:

  • If the option is set to “Select one” then the dependent menu will be empty and that of the textbox.
  • I want to use the required="true" attribute.
  • 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-17T22:03:21+00:00Added an answer on June 17, 2026 at 10:03 pm

    You can use EL in the required attribute. You can let the desired expression evaluate true only when a particular submit button is pressed, or when a particular component value is submitted (and thus by its client ID present in the request parameter map #{param}).

    The following kickoff example should do what you need.

    <p:selectOneMenu binding="#{menu1}" ... required="#{not empty param[submit.clientId]}">
        ...                       
    </p:selectOneMenu>
    <p:selectOneMenu ... required="#{not empty param[menu1.clientId]}">
        ...                       
    </p:selectOneMenu>
    <p:commandButton binding="#{submit}" ... />
    

    This way, the 1st menu is only required when the form’s main submit button is pressed (and thus not when event listeners are fired) and the 2nd menu is only required when the 1st menu has a value.

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

Sidebar

Related Questions

I have a multi-level dropdown menu on my MVC Application and I'm trying to
I have three dropdown lists for date of birth in my multilingual application. I
In my MVC3 application i have a dropdown list. In there i have to
I am creating window c# desktop application I have three columns in my datagridview
I have an application written in pure/basic Java without GUI. I have three classes
i have three java based web application app1,app2 and app3 at production. All 3
In my application, I have three collection objects which store data. The data which
I have a three-tier Windows Forms DB application in VB.NET. I'm using VS 2005.
Within my iPhone application I have a common tab bar with three tabs that
I have an application with three layers (Presentation, Business Logic, and Data Access). In

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.