jsf validate two fields in one time [duplicate]

Best what you can do is to grab the other UIInput component by UIViewRoot#findComponent() inside the validate() method and then determine the submitted value by either UIInput#getSubmittedValue() (when it occurs after the currently validated component in the component tree) or UIInput#getValue() (when it occurs before the current component and thus is already validated). E.g. public … Read more

How to add form validation pattern in Angular 2?

Now, you don’t need to use FormBuilder and all this complicated valiation angular stuff. I put more details from this (Angular 2.0.8 – 3march2016): https://github.com/angular/angular/commit/38cb526 Example from repo : <input [ngControl]=”fullName” pattern=”[a-zA-Z ]*”> I test it and it works 🙂 – here is my code: <form (ngSubmit)=”onSubmit(room)” #roomForm=’ngForm’ > … <input id=’room-capacity’ type=”text” class=”form-control” [(ngModel)]=’room.capacity’ … Read more

Validate order of items inside ui:repeat

There’s physically only one UIInput component whose state changes depending on the current iteration round of UIRepeat. It’s available by just its client ID without the UIRepeat index: findComponent(“formId:inputId”) (the UIRepeat index is only of significance in the client side). However, when the component is programmatically been accessed outside the context of UIRepeat this way, … Read more

Keep open when validation has failed

The PrimeFaces ajax response puts an args object in the scope which has a validationFailed property. You could just make use of it. oncomplete=”if (args &amp;&amp; !args.validationFailed) PF(‘editDialog’).hide()” (the args precheck is necessary to not cause a JS error when an exception is thrown during request) You could refactor it to a reusable JS function … Read more

Angular 2 form validations start date

Based on the answer of santiagomaldonado I have created a generic ValidatorFn that can be used in multiple Reactive Forms with a dynamic return value. export class DateValidators { static dateLessThan(dateField1: string, dateField2: string, validatorField: { [key: string]: boolean }): ValidatorFn { return (c: AbstractControl): { [key: string]: boolean } | null => { const … Read more

Why does allow blank spaces?

That’s normal and natural behaviour and not JSF specific. A blank space may be perfectly valid input. The required=”true” only kicks in on empty inputs, not in filled inputs. In JSF you can however just create a Converter for String class to automatically trim the whitespace. @FacesConverter(forClass=String.class) public class StringTrimmer implements Converter { @Override public … Read more

How to set maxlength attribute on h:inputTextarea

HTML5 + JSF 2.2+ If you’re using HTML5 and JSF 2.2+, specify it as a passthrough attribute. <html … xmlns:a=”http://xmlns.jcp.org/jsf/passthrough”> <h:inputTextarea value=”#{bean.text}” a:maxlength=”2000″ /> HTML4 If you’re on HTML4, then it’s already not supported by HTML itself. It’s only supported on <input> element, not on <textarea> element. That’s also why there’s no such attribute on … Read more