jsf 2 - validator for custom components in JSF fails -
in custom component, have
<composite:interface> <composite:editablevalueholder name="val_pwd" targets="form:pwd"/> <composite:attribute name="name" required="true"/> ..... </composite:interface> <composite:implementation> <h:form id="form"> <h:panelgrid columns="3"> <h:outputtext value="#{cc.attrs.nameprompt}" /> <h:inputtext value="#{cc.attrs.name}" id="name"/> <h:outputtext value="#{cc.attrs.passwordprompt}" /> <h:inputsecret value="#{cc.attrs.pwd}" id="pwd"/> <h:commandbutton value="#{cc.attrs.submitbuttonvalue}" action="#{cc.attrs.actionmethod}"/> </h:panelgrid> </h:form> </composite:implementation>
i have validator,
@facesvalidator("passwordval") public class passwordvalidator implements validator { public passwordvalidator() { super(); } @override public void validate(facescontext facescontext, uicomponent uicomponent, object object) throws validatorexception { if(object instanceof string){ string s = (string) object; if(s.contains("@")) throw new validatorexception(new facesmessage(facesmessage.severity_error, "error","password cannot have @")); } } }
in jsf page, have
<h:body> <util:ccwithcustomval nameprompt="r_name" passwordprompt="r_pwd" name="#{person.name}" pwd="#{person.pwd}" actionmethod="#{person.action}" submitbuttonvalue="r_submit"> <f:validatelength for="val_name" maximum="5"/> <f:validator validatorid="passwordval" for="val_pwd" /> </util:ccwithcustomval> </h:body>
however, fails exception
inputcomponent.xhtml @12,60 <f:validator> adf_faces-60085:parent not instance of editablevalueholder: javax.faces.component.uinamingcontainer@4e18afaa
the problem validator, if comment out page displays
Comments
Post a Comment