Hi Ivy Team

I have a autocomplete. The autocomplete is required field. In autocomplete. I have ajax to handle change event. When autocomplete changes, some fields will be updated below. But When I clear data from autocomplete. The message required is display and some fields are no more update. So I want to do validation only when a button is clicked which submits the form but not when autocomplete changes. How I can do this?

Note: I try using "immediate" attribute in ajax to switch off validation but it is not work.

<p:autoComplete id="select-vendor" 
                widgetVar="select-vendor"
                value="#{purchase.vendor}" 
                dropdown="true" 
                scrollHeight="400"
                completeMethod="#{tenderInformationBean.completeVendor}"
                var="vendor" 
                itemLabel="#{vendor.vendorName}" 
                itemValue="#{vendor}" 
                maxlength="50"
                converter="pojoConverter" 
                cache="true" 
                queryDelay="500"
                rendered="#{!tenderInformationBean.isVendorNotFound}" 
                binding="#{tenderInformationBean.vendorNameAutoComplete}"
                disabled="#{isReadOnlySupplier}" 
                forceSelection="true"
                requiredMessage="#{ivy.cms.co('/ch.ivy.addon.portalkit.ui.jsf/common/requiredFieldMessage')}" >

                <p:ajax event="change" update="vendor-information-fieldset" global="false"
                    listener="#{tenderInformationBean.onSelectVendorName(purchase)}" onstart="if(PF('select-vendor').panel.is(':visible')) return false;"
                    immediate="true"/>

                <p:ajax event="itemSelect" update="vendor-information-fieldset" global="false"
                    listener="#{tenderInformationBean.onSelectVendorName(purchase)}" />

                <f:validator validatorId="awsValidator" />
            </p:autoComplete>

Thanks

asked 11.12.2019 at 23:40

anhle's gravatar image

anhle
216610
accept rate: 0%


Hi

In my opinion is immidiate="true" (as you said) the way to go. But you have two ajax elements and the immidiate is only set on the first. Additionaly the documentation from Primefaces mention no change event on autocomplete widgets (https://primefaces.github.io/primefaces/8_0/#/components/autocomplete).

I think you're problem is that you set this flag on the wrong ajax element. And if this still not working may you can try to add a process="@this" to the ajax element.

PS: On google you can find a lot to Primefaces and JSF stuff too ;)

Kind regards

Lukas

link

answered 12.12.2019 at 03:05

Lukas%20Lieb's gravatar image

Lukas Lieb ♦♦
4411412
accept rate: 61%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×80
×51
×4

Asked: 11.12.2019 at 23:40

Seen: 1,021 times

Last updated: 12.12.2019 at 03:05