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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:00:21+00:00 2026-06-03T04:00:21+00:00

I have a dropdown that holds an account number and two date fields. I

  • 0

I have a dropdown that holds an account number and two date fields. I want to reset the date fields if I change the value of the dropdown. I also have a search button that make a query using these fields (account #, from date, to date).

<fieldset>
    <p:selectOneMenu id="account_search" value="#{accountHistoryBean.account}" converter="accountConverter">
        <f:attribute name="itemsList" value="#{accountHistoryBean.userAccounts}"/>
        <f:selectItems value="#{accountHistoryBean.userAccounts}" var="account" itemLabel="#{account.number}" itemValue="#{account}"/> 
        <p:ajax update="start_date_search, end_date_search" event="change" actionListener="#{accountHistoryBean.resetDates}" process="account_search"/> 
    </p:selectOneMenu>
<fieldset>

<fieldset>
    <p:calendar value="#{accountHistoryBean.fromDate}" id="start_date_search" pattern="dd/MM/yyyy"/>
</fieldset>

<fieldset>
    <p:calendar value="#{accountHistoryBean.toDate}" id="end_date_search" pattern="dd/MM/yyyy"/>
</fieldset>



<fieldset>
    <p:commandLink styleClass="regular_button" action="#{accountHistoryBean.search}" update=":search :accountHistoryList :accountHistoryList:accountHistTable" >
        <span>#{msj.search}</span>
     </p:commandLink>
 </fieldset>

If I do the following:

  1. Change “from Date” and “to Date” fields
  2. Change account field (dropdown with ajax).

Then the dates are resetted to their default value.

But if I do the following:

  1. Change “from Date” and “to Date” fields to DATEX AND DATEY
  2. Press search
  3. Change “from Date” and “to Date” fields to DATEX2 AND DATEY2
  4. Change account field (dropdown with ajax).

Then it changes the Date field to DATEX and DATEY (not the default values).

The methods in the Bean are the following:

public void resetDates()
{
    Calendar calendar = GregorianCalendar.getInstance();
    //By default set toDate as 3/3
    calendar.set(Calendar.MONTH, 2);
    calendar.set(Calendar.DAY_OF_MONTH, 3);
    toDate = calendar.getTime();
    //By default fromDate is one month earlier
    calendar.setTime(toDate);
    calendar.add(Calendar.MONTH, -1);
    fromDate = calendar.getTime();
}

public String search(){
    //Just update the filters
    lazyDataEntityModel.setUpdateData(true);
    return null;
}

Any help?

  • 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-03T04:00:23+00:00Added an answer on June 3, 2026 at 4:00 am

    I changed

    <p:ajax update="start_date_search, end_date_search" 
            event="change" 
            actionListener="#{accountHistoryBean.resetDates}"
            process="account_search"/> 
    

    For

    <p:ajax update="start_date_search, end_date_search" 
            event="change"
            listener="#{accountHistoryBean.resetDates}" 
            process="account_search"/> 
    

    and it worked.

    Thanks

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

Sidebar

Related Questions

I have a dropdown list that when the selected value changes I want to
I have a CSS dropdown menu that is functioning how I want it to
I have a dropdown list that holds all the columns name from the table.
i have a database table that holds the following fields: product_id | design_id |
I have a dropdown that triggers an ajax call when its changed: $('.travel-to').change(function(){ $.ajax({
I have a dropdown list that auto submits a form and performs a search
i have a time dropdown that shows hour in one select, minutes in another
I have a dropdown menu that is filled by a mysql database. I need
For example I have a dropdown box that gets a town from the table
I have a webpage written in HTML. I have a dropdown list that is

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.