0

In primefaces, how to disable form validation ONLY ?

In my code, if I add immediate="true" , it will skip whole process, Apply Request Values, Process Validations and Update Model Values phases, but in my case, I need the bean variable binding to submit a search form . If I remove this immediate setting, it will not submit this form, because orderNum is a bean id.

please refer to this post, PrimeFaces disable validation on cancel button

Thanks.

<h:form id="PurchaseOrderSearchForm">
    <p:panelGrid columns="2" style="margin-top: 0px; width: 100%;">
        <p:outputLabel value="OrderNum:" for="search_orderNum" />
        <p:inputText id="search_orderNum" value="#{purchaseOrderController.searchPurchaseOrder.orderNum}" title="OrderNum"  />                   
    </p:panelGrid>

    <div align="center"  style="margin-top: 5px;"> 
        <p:commandLink   value="#{bundle.Search}"   immediate="true" actionListener="#{purchaseOrderController.search}"  update=":growl,:PurchaseOrderList:datalist"/>                          
    </div>                    
</h:form>
Community
  • 1
  • 1
user595234
  • 6,007
  • 25
  • 77
  • 101
  • I think your expectation is wrong. See http://stackoverflow.com/questions/12960718/trying-to-understand-immediate-true-skipping-validation-when-it-shouldnt – Kukeltje Apr 13 '15 at 20:34

1 Answers1

0

You seem to be binding your p:inputText to the entity (PurchaseOrder) bean's field. But you say this is a search form, so why would you do that? You should bind it to a simple non-persistent field in your controller. You don't need immediate here.

<p:inputText id="search_orderNum" value="#{purchaseOrderController.searchQueryString}" />

And then in your action method you can do whatever you want with the searchQueryString value.

Vsevolod Golovanov
  • 4,068
  • 3
  • 31
  • 65