« Return to Thread: Help with custom tag attribute

Re: Help with custom tag attribute

by Zarar Siddiqi :: Rate this Message:

Reply to Author | View in Thread

There's a difference between saying something is optional by passing
in a null, entirely another to pass in a string and expect it to be
ignored just because its not an integer.

What is the value of maxlength when you pass it in? Is it null or a string?



On Fri, Apr 24, 2009 at 1:16 PM, Felipe Jaekel <fkjaekel@...> wrote:

> 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
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: Help with custom tag attribute