jsf 2 - JSF Validator Problems -


i'm doing following:

i want validation implements interface validator of jsf. have following code:

index.xhtml:

 <h:form  id="inicio">         <p:panel id="panel" header="digite sus credenciales">         <p:focus context="panel"/>         <h:panelgrid id="gridinicio" columns="3" cellpadding="5" >              <p:outputlabel for="identificacion" value="identificacion:"/>             <p:inputtext id="identificacion" onfocus="true" value="#             {ingresomb.usuario.identificacionusuario}"             required="true"             label="identificacion">             <f:validator validatorid="numericovalidator"/>             <f:validatelength minimum="2" />             </p:inputtext>           </h:panelgrid>          <p:commandbutton value="ingresar" update="panel"                         actionlistener="#{ingresomb.verificarinicio()}"                         icon="ui-icon-check" />         </p:panel> 

face-config.xml:

<?xml version="1.0" encoding="utf-8"?> <faces-config     xmlns="http://xmlns.jcp.org/xml/ns/javaee"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"     version="2.2">      <validator>         <validator-id>numericovalidator</validator-id>         <validator-class>co.com.patios.mb.util.validacioncomponentes.numericovalidator</validator-class>     </validator> </faces-config> 

numericovalidator.java:

import javax.faces.validator.validatorexception;  public class numericovalidator implements validator {        public numericovalidator() {         // todo auto-generated constructor stub       }       @override     public void validate(facescontext context, uicomponent component,             object value) throws validatorexception {         string identificacion = (string) value;         if(!validarnumerico(identificacion)){             facesmessage message = new facesmessage();             message.setseverity(facesmessage.severity_error);             message.setdetail("campo debe ser numerico, verifique !!!");             message.setsummary("campo debe ser numerico, verifique !!!");             context.addmessage("inicio", message);               throw new validatorexception(message);         }       }        private boolean validarnumerico(string value){         try{             long.parselong(value);         }catch (numberformatexception e){             return false;         }          return true;     }    } 

now, in index.xhtml reference

<f:validator validatorid="numericovalidator"/> 

validatorid="numericovalidator" id in face-config.xml:

<validator>         <validator-id>numericovalidator</validator-id>         <validator-class>co.com.patios.mb.util.validacioncomponentes.numericovalidator</validator-class>     </validator> 

and co.com.patios.mb.util.validacioncomponentes.numericovalidator class java perform validation.

but, don't understand. why not run ? isn't showed message.

could me ?


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -