【问题标题】:JSF 2 composite component + clientBehaviorJSF 2 复合组件 + clientBehavior
【发布时间】:2013-11-10 10:04:24
【问题描述】:

我有一个复合组件,它是 PrimeFaces autoComplete 的特化。

在某些页面我需要使用itemSelect事件,所以我添加了

<cc:clientBehavior name="itemSelect" event="itemSelect"
                   targets="#{cc.attrs.id}" />

在组件界面中,但没有触发动作。

我错过了什么?

组件代码:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:p="http://primefaces.org/ui" >    

    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="value" required="true" />
        <cc:attribute name="disabled" default="false" />
        <cc:attribute name="required" default="false" />
        <cc:attribute name="size" default="25" />
        <cc:clientBehavior name="itemSelect" event="itemSelect"
            targets="#{cc.attrs.id}" />
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <p:autoComplete disabled="#{cc.attrs.disabled}"
            value="#{cc.attrs.value}"
            completeMethod="#{tecnicoBean.completarViajante}" var="t"
            itemLabel="#{t.nome}" itemValue="#{t}" minQueryLength="2"
            forceSelection="true" converter="entityConverter"
            size="#{cc.attrs.size}" queryDelay="700" label="Técnico:"
            onclick="this.select()" cache="true">
        </p:autoComplete>
    </cc:implementation>
</html>

组件使用:

<ezcomp:tecnicos value="#{sessionScope.tecnicoRdv}">
    <p:ajax event="itemSelect" process="@this" update=":mainPanel"
            listener="#{rdvBean.changeTecnico}" />
</ezcomp:tecnicos>

【问题讨论】:

  • 请在此处发布您的代码之前格式化您的code indentation

标签: ajax jsf-2 primefaces composite-component


【解决方案1】:

cc:clientBehavior 目标 - 本地 ID 列表。为 p:autoComplete 使用唯一 id 的正确方法

<p:autoComplete id="someUniqueId" ... />

并将其链接到 cc:clientBehavior

<cc:clientBehavior name="itemSelect" event="itemSelect"
            targets="someUniqueId" />

【讨论】:

    【解决方案2】:

    终于搞定了。

    我必须将id="#{cc.attrs.id}" 添加到 p:autoComplete 组件中。

    【讨论】:

      猜你喜欢
      • 2012-04-27
      • 2011-09-14
      • 2011-09-28
      • 2011-12-10
      • 2012-06-22
      • 1970-01-01
      • 2011-06-27
      • 2013-03-23
      • 2013-04-22
      相关资源
      最近更新 更多