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

Ravi
  • 133
  • 10
  • Looks like your component was not designed to accept f:valiator. – Alexandre Lavoie May 03 '13 at 05:35
  • How do I make it so? What I've done is the same as in 'core JavaServerFaces 3rd edn' – Ravi May 03 '13 at 05:52
  • Which JSF impl/version? This construct works fine for me in Mojarra 2.1.21 after having fixed `f:validator id` to `f:validator validatorId` (the absence of `validatorId` threw a `TagException` -- as expected) – BalusC May 03 '13 at 11:59
  • Changed id->validatorId, but still fails. I am using Oracle JSF 2.1 – Ravi May 06 '13 at 10:10
  • Oracle? Okay, you're thus using the Mojarra impl. Now yet the version. Which Mojarra version exactly are you using? "JSF 2.1" is merely a specification version. Have you tried Mojarra 2.1.21? – BalusC May 06 '13 at 13:06

0 Answers0