2
I have a JSF system and Primefaces 4.0 and I have a field <p: calendar>
in which I did the treatment to not load dates in the current day Calendar up to -50 years.
But still the user can type it through the keyboard and insert it into the database.
I need a method of not letting a date like that be included, what would be the best way to do it?
Follow an example of the class:
public class DocumentoClienteModel {
private Date dateInicio;
public Date getDtInicio() {
return dtInicio;
}
public void setDtInicio(final Date dtInicio) {
this.dtInicio = dtInicio;
}
}
Oi Bruno, you can implement javascript on your screen?
– RXSD
I think I just need to make sure the security, have any idea?
– Bruno S
If yes, I can help you!
– RXSD
I can, how could I?
– Bruno S
Just one minute....
– RXSD
Beforehand, if my answer is useful, could I vote in favour of it and mark it as a useful response? It would help a lot :)
– RXSD
Absolutely ! I will vote no problem
– Bruno S
I posted an answer, tell me if it helped you, right? Hugs!
– RXSD
I saw answers giving solution to solve your problem on the front end. But you know that the user can circumvent everything that is in the browser, right? I don’t know anything about Java, but probably, the logic could be developed in the backend, for validation if the date is the one you don’t want to let enter. I say this because you quoted "database". If you do not want to let it enter in the database, validate it in the backend. If you do as the answers say, even to use
readonly
, is very easy to cover your app.– Wallace Maxters
On validation at backend vs frontend: https://answall.com/q/13298/112052
– hkotsubo