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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:53:02+00:00 2026-05-31T23:53:02+00:00

I have an autocomplete event that fires correctly once a value is selected. I

  • 0

I have an autocomplete event that fires correctly once a value is selected. I want another event to fire once I erase the value in the textbox and reset the value to null. I was thinking of using the onChange attribute but I was having issues so I reverted back to my original code.

<p:autoComplete id="deviceAuto" dropdown="true" scrollHeight="250" 
                value="#{summaryReportController.device.nickname}" 
                forceSelection="true" 
                completeMethod="#{summaryReportController.deviceComplete}">
    <p:ajax event="itemSelect" 
        listener="#{summaryReportController.handleDeviceSelect}" 
        update="printThis" />  
</p:autoComplete> 
public void handleDeviceSelect(SelectEvent event) {
    String deviceSelect = event.getComponent().getId();
    if (deviceSelect.equalsIgnoreCase("deviceAuto")) {
        Device selectedDevice = deviceMgr.getDevicebyNickname(device.getNickname());
        setDevice(selectedDevice);
    }
    updateInterface();
}
  • 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-31T23:53:03+00:00Added an answer on May 31, 2026 at 11:53 pm

    When you modify the text content of the AutoComplete textfield, the search method (aka. completeMethod) will be called on the backing bean. You can reset the value to null there if you get an empty string.

    Backing Bean

    // insert getter and setter for the device property ...
    
    /** Search for devices by name */
    public List<String> deviceComplete(String search) {
        if (StringUtils.isBlank(search)) {
            setDevice(null);  // textfield was cleared, reset device value!
            return Collections.emptyList();
        } else {
            // search for devices ...
            return deviceNames;
        }
    }
    

    Note that I used Apache Commons StringUtils.isBlank(String) to check if the string was null or did only contain whitespace characters.

    JSF View

    In your XHTML file you probably want to listen to any Ajax event to update your view — or you figure out the event you need (blur, change, whatever) yourself:

    <p:autoComplete ...>
        <p:ajax event="itemSelect" listener="..." update="..." />
        <p:ajax process="@this" update="..." />
    </p:autocomplete>
    

    I hope this helps.


    An alternative could be something like a “clear” or “reset” button next to the search textfield to make it clear to the user that the value will be cleared.

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

Sidebar

Related Questions

I have a textbox that is wired up using jQuery UI 1.8.4 autocomplete. I
I have a autocomplete textbox, in that textbox am getting employee names. If I
I have a simple autocomplete field that spits out a bunch of suggested words
So I have a jquery autocomplete on a testbox that searches the database for
I have a jQuery autocomplete that works in most browsers but only kind of
I wrote code that fails to use the JQuery autocomplete to fire a result
I have multiple autocomplete textbox paired with multiple hidden fields. How do I do
I have a field accountname that uses Jquery autosuggest in a textbox. Here as
I have a Textbox with the id text (#text) with has an autocomplete like
I have just built a custom autocomplete component using jquery. My problem is that

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.