2 Replies Latest reply on Jan 14, 2016 6:36 AM by szilardk

    Help with custom tag attribute

    fkj

      I have a custom tag that is composed by a <h:outputLabel /> + <h:inputText />. I need the maxlength 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