« Return to Thread: Help with custom tag attribute

Help with custom tag attribute

by FkJ :: Rate this Message:

Reply to Author | View in Thread

I have a custom tag that is composed by a <h:outputLabel /> + <h:inputText />. I need the maxlength attribute to be optional. The problem is that when I use <f:attribute /> I get a class cast exception.

Tag:

<ui:composition
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:c="http://java.sun.com/jstl/core"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
>
    <h:outputLabel value="#{label}" />
    <h:inputText
        label="#{label}"
        value="#{value}"
    >
        <c:if test="#{! empty maxlength}">
            <f:attribute
                name="maxlength"
                value="#{maxlength}"
            />
        </c:if>
        <ui:insert />
    </h:inputText>
</ui:composition>
   



Exception:

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
   

Any ideas?

Thanks,
Felipe

 « Return to Thread: Help with custom tag attribute