TagException: Components#includeCompositeComponent and required attributes #167

Closed
aadhoc opened this Issue Sep 18, 2015 · 1 comment

Projects

None yet

2 participants

@aadhoc
aadhoc commented Sep 18, 2015

When I make some attributes required, they appear to be validated before I can set them when includeCompositeComponent() returns. The error below shows the exception when required="true", but no errors when required="false".

Workaround: Make all attributes required="false"

Composite:

<?xml version="1.0" encoding="ISO-8859-1" ?>

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:composite="http://java.sun.com/jsf/composite"
    xmlns:h="http://java.sun.com/jsf/html">

    <composite:interface>
        <composite:attribute name="title" required="true" type="String"/>
    </composite:interface>

    <composite:implementation>
        <h:outputText value="#{cc.attrs.title}"/>
    </composite:implementation>
</html>

Code:

        UIComponent composite = Components.includeCompositeComponent(
                topGroup,
                "com/aadhoc",
                "TestControl.xhtml",
                "test_control");
        composite.getAttributes().put("title", "This is a test");

Exception:

Caused by: javax.faces.view.facelets.TagException: null The following attribute(s) are required, but no values have been supplied for them: title. 
    at com.sun.faces.facelets.tag.composite.InterfaceHandler.validateComponent(InterfaceHandler.java:232)
    at com.sun.faces.facelets.tag.composite.InterfaceHandler.apply(InterfaceHandler.java:125)
    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
    at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
    at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
    at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:312)
    at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:371)
    at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:326)
    at org.omnifaces.util.Components.includeCompositeComponent(Components.java:615)
@BalusC BalusC closed this in 5264f37 Sep 22, 2015
@BalusC
Member
BalusC commented Sep 22, 2015

I added a new includeCompositeComponent() method taking an attribute map. It's available in today's latest snapshot. Can you give it a try?

@BalusC BalusC added a commit that referenced this issue Sep 23, 2015
@BalusC BalusC #167: fix attribute mapping fa187a3
@BalusC BalusC added the bug label Oct 3, 2015
@BalusC BalusC added a commit that referenced this issue Oct 24, 2015
@BalusC BalusC #167: migrate to JSF 2.2 approach 30a8e6a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment