@Override
    public void apply(FaceletContext ctx, UIComponent parent) throws IOException {
        String path = this.src.getValue(ctx);
        if (path == null || path.length() == 0) {
            return;
        }

        // wrap the original mapper - this is important when some objects passed into include via ui:param
        // because ui:param invokes setVariable(...) on the set variable mappper instance
        VariableMapper origVarMapper = ctx.getVariableMapper();
        ctx.setVariableMapper(new VariableMapperWrapper(origVarMapper));

        try {
            this.nextHandler.apply(ctx, null);

            ValueExpression ve = (this.value != null) ? this.value.getValueExpression(ctx, Object.class) : null;
            Object objValue = (ve != null) ? ve.getValue(ctx) : null;
            if (objValue == null) {
                // no include
                return;
            }

            int size = 0;

            if (objValue instanceof List) {
                size = ((List) objValue).size();
            }
            else if (objValue.getClass().isArray()) {
                size = ((Object[]) objValue).length;
            }

            if (this.name == null) {
                // no include
                return;
            }

            ExpressionFactory exprFactory = ctx.getFacesContext().getApplication().getExpressionFactory();

            String strName = this.name.getValue(ctx);

            // generate unique Id as a valid Java identifier and use it as variable for the provided value expression
            String uniqueId = "a" + UUID.randomUUID().toString().replaceAll("-", "");
            ctx.getVariableMapper().setVariable(uniqueId, ve);

            // include facelet multiple times
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < size; i++) {
                if ((strName != null) && (strName.length() != 0)) {
                    // create a new value expression in the array notation and bind it to the variable "name"
                    sb.append("#{");
                    sb.append(uniqueId);
                    sb.append("[");
                    sb.append(i);
                    sb.append("]}");

                    ctx.getVariableMapper().setVariable(strName,
                        exprFactory.createValueExpression(ctx, sb.toString(), Object.class));
                }

                // included facelet can access the created above value expression
                ctx.includeFacelet(parent, path);

                // reset for next iteration
                sb.setLength(0);
            }

            // fix for cc:insertChildren (com.sun.faces.facelets.tag.composite.InsertChidrenHandler)
            if (size > 0) {
                Integer idx = (Integer) parent.getAttributes().get("idx");
                if (idx != null) {
                    parent.getAttributes().put("idx", idx + size);
                }
            }
        }
        catch (IOException e) {
            throw new TagAttributeException(this.tag, this.src, "Invalid path : " + path);
        }
        finally {
            // restore original mapper
            ctx.setVariableMapper(origVarMapper);
        }
    }
Tag handler to include a facelet multiple times with different contextes (objects from "value").
The attribute "value" can be either of type java.util.List or array.
If the "value" is null, the tag handler works as a standard ui:include.
primefaces-integration-tests/src/main/java/org/primefaces/integrationtests/common/IncludesTagHandler.java