【问题标题】:Unable to use p:overlaypanel inside composite component无法在复合组件内使用 p:overlaypanel
【发布时间】:2013-10-08 19:58:18
【问题描述】:

我正在尝试创建一个复合组件,它将值显示为覆盖面板。但它返回以下错误; 在视图中找不到组件“j_idt58:reviewDataTable:0:overrideCol”

overrideVersionDetails.xhtml:(复合组件)

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:cc="http://java.sun.com/jsf/composite"
    xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
    xmlns:c="http://java.sun.com/jsp/jstl/core">

    <cc:interface>
        <cc:attribute name="forId" type="java.lang.String" required="true" />
        <cc:attribute name="forValue" type="java.lang.Object" />
    </cc:interface>

    <cc:implementation>
        <p:overlayPanel for="#{cc.attrs.forId}" my="left bottom">
            #{cc.attrs.forValue}
        </p:overlayPanel>
    </cc:implementation>
</ui:composition>

它在另一个页面中使用:

<h:form>
....
...
<p:dataTable .....>
....
    <p:column sortBy="#{dto.isSameCycleOverride}" width="100">
      <f:facet name="header">
          Override
      </f:facet>
      <h:commandLink id="overrideCol" binding="#{overrideCol}"
        value="#{(dto.isSameCycleOverride) ? 'Yes' : 'No'}" />
     <comp:overrideVersionDetails forId="#{overrideCol.clientId}"
     forValue="#{dto.message}" />
    </p:column>
....
</p:dataTable>
</h:form>

非常感谢任何帮助。

【问题讨论】:

    标签: jsf-2 composite-component


    【解决方案1】:

    我不使用 Primefaces,但我会使用 RichFaces:

    <comp:overrideVersionDetails forId="#{rich:clientId('overrideCol')}"
                                 forValue="#{dto.message}" />
    

    做你想做的事。

    在 SO 的帮助下: Rich Faces rich:clientId in Primefaces? 看来你可以这样做:

    ...
     <h:commandLink id="overrideCol" value="#{(dto.isSameCycleOverride) ? 'Yes' : 'No'}" />
     <comp:overrideVersionDetails forId="#{p:component('overrideCol')}"
     forValue="#{dto.message}" />
    ...
    

    现在看看这是否比在数据表中使用 binding 更有效...

    【讨论】:

      猜你喜欢
      • 2011-07-25
      • 2011-12-19
      • 2018-05-04
      • 2015-02-25
      • 2011-10-07
      • 2011-12-14
      • 2018-03-11
      • 2014-12-16
      • 2016-06-12
      相关资源
      最近更新 更多