Re: Unable to have an error 404 not found with a pattern validator

Splash Forums PrettyFaces Users Unable to have an error 404 not found with a pattern validator Re: Unable to have an error 404 not found with a pattern validator

#21279

weljoweb
Participant

Hi,

I have the same issue, please see http://ocpsoft.com/support/topic/unable-to-navigate-to-onerror-outcome-during-query-param-validation for my analysis.

As an alternative what I did was to do my validation inside the action. Then set the desired response code e.g.

/**

* Action for pretty faces url redirection

*

*/

public String loadPage() {

/**

* PrettyFaces won’t allow forwards on error

* except to standard 404 so for now we handle validation here.

*/

ParameterValidator validator = getValidator();

try {

validator.validateProductId(context, null, productId);

} catch (Exception e) {

productId = null;

}

if (productId != null) {

initialize();

return null;

} else {

FacesContext.getCurrentInstance().getExternalContext().getResponse();

resp.setStatus(SC_NOT_FOUND);

return “showProductNotFoundPage”;

}

}