Extend o:validateOrder to provide optional attribute #47

Closed
pholding opened this Issue Jul 21, 2014 · 2 comments

Projects

None yet

2 participants

@pholding

Would it be possible to extend the o:validateOrder component to provide an optional attribute so that if any of the client IDs specified in the components attribute contain a null value then the validation is skipped. The use case I've got is a form that has a start date and end date component both of which are optional and the user can popuate either or both components, and I would only like the o:validateOrder component to execute its validation if both start and end date components have been populated.

Whilst not needed in my use case another useful extension would be to include an o:validateOrder component which is based on o:validateAllOrNone

@BalusC
Member
BalusC commented Jul 22, 2014

You could use the disabled attribute for that.

<x:inputDate id="start" binding="#{start}" />
<x:inputDate id="end" binding="#{end}" />
<o:validateOrder components="start end" disabled="#{empty start.value or empty end.value}" />
@BalusC BalusC closed this in 61aae0d Aug 9, 2014
@BalusC
Member
BalusC commented Aug 9, 2014

After a thought, I decided to remove nulls (and empty strings) from to-be-validated values. This responsibility should be up to the required="true" or @NotNull/@NotBlank.

The change is available in today's 2.0 snapshot https://oss.sonatype.org/content/repositories/snapshots/org/omnifaces/omnifaces/2.0-SNAPSHOT/ (which requires JSF 2.2 / CDI 1.0 though). Please give it a try.

@BalusC BalusC added a commit that referenced this issue Aug 18, 2014
@BalusC BalusC Fix #47: Skip null/empty values in o:validateOrder (this job is actually
up to required="true")

Conflicts:
	src/main/java/org/omnifaces/component/validator/ValidateOrder.java
	src/main/java/org/omnifaces/util/Utils.java
230393a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment