Search code examples
jsfjsf-2jsf-2.2

Can't use VueJS attribute prefixes in JSF facelets


I put something like this in my JSF facelets:

<html xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
    <f:view>
        <h:head></h:head>
        <h:body>
            <todo-item
                v-for="item in groceryList"
                v-bind:todo="item"
                v-bind:key="item.id">
            </todo-item>
            ...
        </h:body>
    </f:view>
</html>

And get the error:

The prefix "v-bind" for attribute "v-bind:todo" associated with an element type "todo-item" is not bound.

I understand what the problem is. The namespace is not defined on the HTML element. But how could I? I tried using xmlns:p="http://xmlns.jcp.org/jsf/passthrough", p:v-bind:todo and p:v-bind:key, but that was a long shot and didn't work.


Solution

  • I ended up simply doing like this:

    <html xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:v-bind="http://xmlns.jcp.org/jsf/passthrough">
        <f:view>
            <h:head></h:head>
            <h:body>
                <todo-item
                    v-for="item in groceryList"
                    v-bind:todo="item"
                    v-bind:key="item.id">
                </todo-item>
                ...
            </h:body>
        </f:view>
    </html>