0
votes

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>
1
I think your expectation is wrong. See stackoverflow.com/questions/12960718/…Kukeltje

1 Answers

0
votes

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.