What’s the appropriate HTTP status code to return if a user tries logging in with an incorrect username / password, but correct format?

If you are strictly using the HTTP authentication framework provided by RFC 7235 for your REST API, the correct HTTP code would actually be 401. From the RFC: The 401 (Unauthorized) status code indicates that the request has not been applied because it lacks valid authentication credentials for the target resource. The server generating a … Read more

Using validator with a variable attribute in ui:repeat

This is indeed specified/expected behavior. The attributes of taghandlers like <f:validateXxx> are evaluated during view build time. So they can’t refer a variable which is only available during view render time like the currently iterated variable of <ui:repeat>. It would indeed work when you use an iterator which runs during view build time like JSTL … Read more

How to trigger args.validationFailed in PrimeFaces oncomplete

If utilizing the JSF-builtin validation facility (i.e. just use validators which throw ValidatorException the usual way with therein the desired faces message) is really not an option for some reason (I’d really think twice, no, thrice about working around JSF validation facility), then you can always use FacesContext#validationFailed() to signal JSF that the validation has … Read more

How to display dialog only on complete of a successful form submit

The PrimeFaces ajax response puts an args object in the JS scope which has a validationFailed property. You could just check for that in the oncomplete. <p:commandButton … oncomplete=”if (args &amp;&amp; !args.validationFailed) dialogaboutDEQ.show()” /> If you’re performing validation in action method instead of in a normal validator, and you can’t rework that, then you need … Read more

Change the default message “Validation Error: Value is required” to just “Value is required”

Either use the input component’s requiredMessage attribute: <x:inputXxx … required=”true” requiredMessage=”Value is required” /> Or create a properties file in the classpath which contains the custom message template: javax.faces.component.UIInput.REQUIRED = Value is required. and is been registered as message bundle in faces-config.xml: <application> <message-bundle>com.example.CustomMessages</message-bundle> </application> The above example assumes that the file name is CustomMessages.properties … Read more