Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF and partial validation

Tags:

jsf

primefaces

I wonder if there is a trick to validate all fields in a form except one ?

Something like :

<p:remoteCommand process="@form^F100"  .... />

Obviously, this doesn't work...

If I have 100 fields in a form, is there any way or shortcut to validate all exception F100 for example ?

Am I doomed to use

<p:remoteCommand process="F1 F2 F3 F4 F5 F6 .... F99"  .... />

?

like image 622
Olivier J. Avatar asked Jan 06 '13 20:01

Olivier J.


1 Answers

You can use PrimeFaces Selectors (PFS) for this. This allows you using jQuery CSS selector syntax in process and update attributes of PrimeFaces ajax components. You could for example use a noprocess class on the component which you'd like to skip and use :not(.noprocess) selector.

Your particular requirement can then be solved as follows:

<h:form>
    <h:inputText ... />
    <h:inputText ... />
    <h:inputText ... />
    ...
    <h:inputText ... />
    <h:inputText ... />
    <h:inputText ... styleClass="noprocess" />
    <p:remoteCommand ... process="@(form :not(.noprocess))"/>
</h:form>

This example will process the entire form expect of inputs having class="noprocess" in the client side.

like image 74
BalusC Avatar answered Oct 04 '22 03:10

BalusC