Search code examples
jsfjsf-2custom-component

composite attributes returns null in jsf custom components


I am implementing my custom component like below. Placed this file web-> resource folder

<html
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:composite="http://java.sun.com/jsf/composite"
      >
    <h:body>
        <composite:interface>
            <composite:attribute name="width" default="300"/>
            <composite:attribute name="height" default="400"/>
        </composite:interface>
        <composite:implementation>
            <h:inputText style="height: #{composite.attrs.height}px"></h:inputText>
            <span> #{composite.attrs.height}</span>
        </composite:implementation>
    </h:body>
</html>

but attrs.height return nothing.

Custom component is used like below

<my:mycustom  height="40"></my:mycustom>

What i have done mistakes here. Anyone please help me to do this.


Solution

  • I have found the issue, used the namespaces as composite to get the attribute(#{composite.attrs.height}) But this is not correct it seems and used cc instead of composite and its returns correctly.

    {cc.attrs.height}