The client validation in myfaces is designed to run at onsubmit event of the form but I think stuff like these can be very handy for the onkeypress events. (maxlength, integer only)
If there is a NumberConverter with integeronly set true, onkeypress can be decorated to call js events. This is similar to the topic I've discussed with Martin once, "the client side converters".
Cagatay,
On 6/26/06, Mert Çalışkan <[EMAIL PROTECTED]> wrote:
I did a similiar thing for UIInput components before. With _javascript_ calls the user was only capable of inputting numeric characters.You can use a _javascript_ like that, but you should also check for the keyCode for "." hence the code only checks for 0-9 numeric inputs.
Cagatay will you add scripting stuff like that to the client-side validation of myfaces?What's the plan?Regards,Mert
On 6/26/06, Cagatay Civici <[EMAIL PROTECTED] > wrote:Hi,
This is because converter takes place before the validators.
Maybe you could try some _javascript_ tricks to disable user from submitting invalid data?
Cagatay
On 6/26/06, José Luis / Dpto Informatica <[EMAIL PROTECTED] > wrote:Hi,
Is there any way to validate what the user inputs in the InputDate control ?
If a user input a character in the day field then I get the next error :
<pre>
java.lang.NumberFormatException : For input string: "A"
java.lang.NumberFormatException.forInputString
(NumberFormatException.java:48)java.lang.Integer.parseInt(Integer.java:447)java.lang.Integer.parseInt(Integer.java:497)
org.apache.myfaces.custom.date.HtmlInputDate$UserData.parse
(HtmlInputDate.java:208)org.apache.myfaces.custom.date.HtmlDateRenderer.getConvertedValue
(HtmlDateRenderer.java:277)javax.faces.component.UIInput.getConvertedValue
(UIInput.java:289)javax.faces.component.UIInput.validate(UIInput.java :265)
javax.faces.component.UIInput.processValidators(UIInput.java:144)
javax.faces.component.UIForm.processValidators(UIForm.java:68)
javax.faces.component.UIComponentBase.processValidators (UIComponentBase.java:417)javax.faces.component.UIViewRoot.processValidators
(UIViewRoot.java:142)org.apache.myfaces.lifecycle.LifecycleImpl.processValidations
(LifecycleImpl.java:240)org.apache.myfaces.lifecycle.LifecycleImpl.execute
(LifecycleImpl.java:76)javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
</pre>
I've tried writing a validator method in mi backing bean but before I could read the new value the error has already been tigered.
Thank you very much in advance.