不能在 JSF facelets 中使用 VueJS 属性前缀

Can't use VueJS attribute prefixes in JSF facelets

我在我的 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>

并得到错误:

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

我明白问题出在哪里了。名称空间未在 HTML 元素上定义。但是我怎么能呢?我尝试使用 xmlns:p="http://xmlns.jcp.org/jsf/passthrough"p:v-bind:todop:v-bind:key,但这是一个很长的尝试,没有奏效。

我最终只是这样做了:

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

VUE 和 JSF2 之间的结合是地狱般的。我想使用 JSF2 的 facelets 模板和模型绑定以及 VUE

的 front-end 魔力

最后的陈述如下:

xmlns:v-on="http://xmlns.jcp.org/jsf/passthrough"
xmlns:v-bind="http://xmlns.jcp.org/jsf/passthrough"

将 JSF 绑定到支持 bean 并绑定到 vue 以进行前端验证

<h:inputText a:placeholder="eMail" maxlength="17" value="#{LoginBean.email}" a:v-model="email"/>

绑定css类和使用vue的条件渲染

<div class="button" v-bind:class="{ disabled: !login_enabled }">
    <span v-if="login_enabled">
        <h:commandLink action="#{LoginBean.submit}">
            <span class="button-title">Submit</span>
            <f:ajax execute="@form"/>
        </h:commandLink>
    </span>
    <span v-if="!login_enabled" class="button-title">Submit</span>
</div>

老实说,不确定这是否适合我的项目。目前有效,稍后会看到。