0

In my custom component, I 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 a 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 my JSF page, I 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, it fails with exception

InputComponent.xhtml @12,60 <f:validator> ADF_FACES-60085:Parent not an instance of
 EditableValueHolder: javax.faces.component.UINamingContainer@4e18afaa

The problem is with my validator, if I comment it out the page displays

4

0 回答 0