Let\'s say that I have an application which manages users. You can add new user, delete them, edit detail etc. Each user has na ID and has detail page on URL like this:
Just attach a validator to the id view parameter and if validation fails, set error code 404 on the response.
e.g.
Consider this simple Facelet:
And the following backing bean:
@ManagedBean
@ViewScoped
public class MyBean {
private Long id;
public void validate(FacesContext context, UIComponent component, Object object) {
// Do some validation
// And if failed:
context.getExternalContext().setResponseStatus(404);
context.responseComplete();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}