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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:57:39+00:00 2026-06-09T18:57:39+00:00

I have a problem regarding jsf autocomplete elements. I want my page to have

  • 0

I have a problem regarding jsf autocomplete elements. I want my page to have an autocomplete element and after a user selects a value from the field, another field is automatically created. The maksimum number of autocomplete field is 3, so after the 3rd one, the 4th one is disabled:

<h:outputLabel for="fieldsOfStudy" value="#{amsg.fieldsOfStudy}"/>

<p:outputPanel id="fieldsOfStudy" autoUpdate="true" layout="block">
     <ui:repeat value="#{cc.attrs.offer.fieldsOfStudy}" var="studyField" varStatus="status">

          <h:panelGroup id="studyField" layout="block">
              <h:outputText value="#{amsg.handleGetObject(enumHelper.toMessageKey(studyField))}"/>
              <p:commandLink action="#{cc.attrs.offer.removeFieldOfStudy(status.index)}" process="@this"
                       update="@([id$=fieldsOfStudyAutocomplete])" styleClass="ui-icon ui-icon-close"/>
          </h:panelGroup>

     </ui:repeat>
</p:outputPanel>

<h:message for="fieldsOfStudy" errorClass="error"/>

<h:panelGroup id="fieldsOfStudyAutocomplete">
     <p:autoComplete value="#{offerBean.selectedFieldOfStudy}" dropdown="true" required="#{empty cc.attrs.offer.fieldsOfStudy}"
                       completeMethod="#{offerBean.completeFieldsOfStudy}" disabled="#{cc.attrs.offer.fieldsOfStudy.size() &gt;= 3}"
                       itemValue="#{p}" var="p" itemLabel="#{amsg.handleGetObject(enumHelper.toMessageKey(p))}" styleClass="xLargeInput">
              <p:ajax event="itemSelect" process="@this" update="@this"/>
     </p:autoComplete>
</h:panelGroup>

Everything works good like this, but the problem is that every time a user presses the Save button if the “Field of study” list has 1 selected element from the autocomplete there will be another one in the list with a null value. If there are 2 selected “field of studies” the 3rd one will be also created but ill have a null value. If there are 3 selected “fields of studies”, then there wont be any 4th element in the list.

Is there any way I can set the autocomplete to ignore null fields? In other words, if a user doesnt select anything from the autocomplete, how not to pass null values to the DTO?

  • 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-09T18:57:41+00:00Added an answer on June 9, 2026 at 6:57 pm

    I found a way. When setting up the value in the bean you can easily put an if statement like this:

    public void setSelectedFieldOfStudy(FieldOfStudy selectedFieldOfStudy) {
        if (selectedFieldOfStudy != null) {
            this.emptyOffer.getFieldsOfStudy().add(selectedFieldOfStudy);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem regarding a JSON string grabbed from WordPress custom post meta.
i have a problem regarding the responseXML of ajax.. I have this code from
I seem to have stumbled over a problem regarding saving an xml file from
I have a problem regarding a query where i want to only display data
I have a problem regarding getting the path of a user control. The scenario
I have a problem regarding relative positioning. I want the body to have a
I have one problem regarding retriving data from database. I have created one database
I have JSF page has two drop down lists and I want to load
I have a problem regarding this two values from my textboxes (text, text2), seems
I have a problem regarding StartUp Url in WPF. I have a LoginView.xaml and

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.