Note that there are some explanatory texts on larger screens.

plurals
  1. POJSF autocomplete ignoring null values
    primarykey
    data
    text
    <p>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:</p> <pre><code>&lt;h:outputLabel for="fieldsOfStudy" value="#{amsg.fieldsOfStudy}"/&gt; &lt;p:outputPanel id="fieldsOfStudy" autoUpdate="true" layout="block"&gt; &lt;ui:repeat value="#{cc.attrs.offer.fieldsOfStudy}" var="studyField" varStatus="status"&gt; &lt;h:panelGroup id="studyField" layout="block"&gt; &lt;h:outputText value="#{amsg.handleGetObject(enumHelper.toMessageKey(studyField))}"/&gt; &lt;p:commandLink action="#{cc.attrs.offer.removeFieldOfStudy(status.index)}" process="@this" update="@([id$=fieldsOfStudyAutocomplete])" styleClass="ui-icon ui-icon-close"/&gt; &lt;/h:panelGroup&gt; &lt;/ui:repeat&gt; &lt;/p:outputPanel&gt; &lt;h:message for="fieldsOfStudy" errorClass="error"/&gt; &lt;h:panelGroup id="fieldsOfStudyAutocomplete"&gt; &lt;p:autoComplete value="#{offerBean.selectedFieldOfStudy}" dropdown="true" required="#{empty cc.attrs.offer.fieldsOfStudy}" completeMethod="#{offerBean.completeFieldsOfStudy}" disabled="#{cc.attrs.offer.fieldsOfStudy.size() &amp;gt;= 3}" itemValue="#{p}" var="p" itemLabel="#{amsg.handleGetObject(enumHelper.toMessageKey(p))}" styleClass="xLargeInput"&gt; &lt;p:ajax event="itemSelect" process="@this" update="@this"/&gt; &lt;/p:autoComplete&gt; &lt;/h:panelGroup&gt; </code></pre> <p>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.</p> <p>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?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload